diff --git a/solution/1300-1399/1386.Cinema Seat Allocation/README.md b/solution/1300-1399/1386.Cinema Seat Allocation/README.md index 8d2bd12df1f4f..82d1d1fc8b018 100644 --- a/solution/1300-1399/1386.Cinema Seat Allocation/README.md +++ b/solution/1300-1399/1386.Cinema Seat Allocation/README.md @@ -5,7 +5,8 @@ ## 题目描述 -

+ +![](./images/cinema_seats_1.png)

如上图所示,电影院的观影厅中有 n 行座位,行编号从 1 到 n ,且每一行内总共有 10 个座位,列编号从 1 到 10 。

@@ -17,7 +18,7 @@

示例 1:

-

+![](./images/cinema_seats_3.png)
输入:n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
 输出:4
diff --git a/solution/1300-1399/1386.Cinema Seat Allocation/README_EN.md b/solution/1300-1399/1386.Cinema Seat Allocation/README_EN.md
index e9f59a854510e..0c9c001410f46 100644
--- a/solution/1300-1399/1386.Cinema Seat Allocation/README_EN.md	
+++ b/solution/1300-1399/1386.Cinema Seat Allocation/README_EN.md	
@@ -4,7 +4,7 @@
 
 ## Description
 
-

+![](./images/cinema_seats_1.png)

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.

@@ -15,7 +15,7 @@

 

Example 1:

-

+![](./images/cinema_seats_3.png)
 Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
diff --git a/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_1.png b/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_1.png
new file mode 100644
index 0000000000000..5835268cb3edb
Binary files /dev/null and b/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_1.png differ
diff --git a/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_3.png b/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_3.png
new file mode 100644
index 0000000000000..ce78dee4c8bfe
Binary files /dev/null and b/solution/1300-1399/1386.Cinema Seat Allocation/images/cinema_seats_3.png differ
diff --git a/solution/1300-1399/1388.Pizza With 3n Slices/README.md b/solution/1300-1399/1388.Pizza With 3n Slices/README.md
index a69968a393154..1322570777b6f 100644
--- a/solution/1300-1399/1388.Pizza With 3n Slices/README.md	
+++ b/solution/1300-1399/1388.Pizza With 3n Slices/README.md	
@@ -22,7 +22,7 @@
 
 

示例 1:

-

+![](./images/sample_3_1723.png)
输入:slices = [1,2,3,4,5,6]
 输出:10
@@ -31,7 +31,7 @@
 
 

示例 2:

-

+![](./images/sample_4_1723.png)
输入:slices = [8,9,8,6,1,1]
 输出:16
diff --git a/solution/1300-1399/1388.Pizza With 3n Slices/README_EN.md b/solution/1300-1399/1388.Pizza With 3n Slices/README_EN.md
index 2f50a3ac5966d..76311cfe89b2f 100644
--- a/solution/1300-1399/1388.Pizza With 3n Slices/README_EN.md	
+++ b/solution/1300-1399/1388.Pizza With 3n Slices/README_EN.md	
@@ -1,89 +1,136 @@
-# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices)
-
-[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md)
-
-## Description
-
-

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
  • -
- -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices) + +[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md) + +## Description + +

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:

+ + +![](./images/sample_3_1723.png) + +
+
+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:

+ + +![](./images/sample_4_1723.png) + + + +
+
+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
  • +
+ +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_3_1723.png b/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_3_1723.png new file mode 100644 index 0000000000000..ad32e4fe01974 Binary files /dev/null and b/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_3_1723.png differ diff --git a/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_4_1723.png b/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_4_1723.png new file mode 100644 index 0000000000000..34e8bee8362e8 Binary files /dev/null and b/solution/1300-1399/1388.Pizza With 3n Slices/images/sample_4_1723.png differ diff --git a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README.md b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README.md index 0e88fe6a81c85..1739d68b189e6 100644 --- a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README.md +++ b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README.md @@ -16,7 +16,7 @@
  • 6 表示连接右单元格和上单元格的街道。
  • -

    +![](./images/main.png)

    你最开始从左上角的单元格 (0,0) 开始出发,网格中的「有效路径」是指从左上方的单元格 (0,0) 开始、一直到右下方的 (m-1,n-1) 结束的路径。该路径必须只沿着街道走

    @@ -28,7 +28,7 @@

    示例 1:

    -

    +![](./images/e1.png)
    输入:grid = [[2,4,3],[6,5,2]]
     输出:true
    @@ -37,7 +37,7 @@
     
     

    示例 2:

    -

    +![](./images/e2.png)
    输入:grid = [[1,2,1],[1,2,1]]
     输出:false
    diff --git a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README_EN.md b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README_EN.md
    index e0c9d6d02d961..f6247e67472cd 100644
    --- a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README_EN.md	
    +++ b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/README_EN.md	
    @@ -14,7 +14,7 @@ Given a m x n grid. Each cell of the grid6 which means a street connecting the right cell and the upper cell.
     
     
    -

    +![](./images/main.png)

    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.

    @@ -24,7 +24,9 @@ Given a m x n grid. Each cell of the grid 

    Example 1:

    - + +![](./images/e1.png) +
     Input: grid = [[2,4,3],[6,5,2]]
     Output: true
    @@ -32,7 +34,9 @@ Given a m x n grid. Each cell of the grid
     
     

    Example 2:

    - + +![](./images/e2.png) +
     Input: grid = [[1,2,1],[1,2,1]]
     Output: false
    diff --git a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e1.png b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e1.png
    new file mode 100644
    index 0000000000000..014fbcba1f2e5
    Binary files /dev/null and b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e1.png differ
    diff --git a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e2.png b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e2.png
    new file mode 100644
    index 0000000000000..f3855555e3ab7
    Binary files /dev/null and b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/e2.png differ
    diff --git a/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/main.png b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/main.png
    new file mode 100644
    index 0000000000000..31d85c6d48034
    Binary files /dev/null and b/solution/1300-1399/1391.Check if There is a Valid Path in a Grid/images/main.png differ
    diff --git a/solution/1400-1499/1401.Circle and Rectangle Overlapping/README.md b/solution/1400-1499/1401.Circle and Rectangle Overlapping/README.md
    index 3440f3ea47368..1b076ac5b044f 100644
    --- a/solution/1400-1499/1401.Circle and Rectangle Overlapping/README.md	
    +++ b/solution/1400-1499/1401.Circle and Rectangle Overlapping/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_4_1728.png)
    输入:radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
     输出:true
    @@ -24,7 +24,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1728.png)
    输入:radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
     输出:true
    @@ -32,7 +32,7 @@
     
     

    示例 3:

    -

    +![](./images/sample_6_1728.png)
    输入:radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
     输出:true
    diff --git a/solution/1400-1499/1401.Circle and Rectangle Overlapping/README_EN.md b/solution/1400-1499/1401.Circle and Rectangle Overlapping/README_EN.md
    index d4563d53f2051..4cb311b768f91 100644
    --- a/solution/1400-1499/1401.Circle and Rectangle Overlapping/README_EN.md	
    +++ b/solution/1400-1499/1401.Circle and Rectangle Overlapping/README_EN.md	
    @@ -13,7 +13,7 @@
     

     

    Example 1:

    -

    +![](./images/sample_4_1728.png)
     Input: radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
    @@ -23,7 +23,7 @@
     
     

    Example 2:

    -

    +![](./images/sample_2_1728.png)
     Input: radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
    @@ -32,7 +32,7 @@
     
     

    Example 3:

    -

    +![](./images/sample_6_1728.png)
     Input: radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
    diff --git a/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_2_1728.png b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_2_1728.png
    new file mode 100644
    index 0000000000000..e92ff53da4c82
    Binary files /dev/null and b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_2_1728.png differ
    diff --git a/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_4_1728.png b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_4_1728.png
    new file mode 100644
    index 0000000000000..c1fedf1dcc09f
    Binary files /dev/null and b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_4_1728.png differ
    diff --git a/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_6_1728.png b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_6_1728.png
    new file mode 100644
    index 0000000000000..2a9df2c4cfdf3
    Binary files /dev/null and b/solution/1400-1499/1401.Circle and Rectangle Overlapping/images/sample_6_1728.png differ
    diff --git a/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README.md b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README.md
    index ea60c5290f5ce..8af1aa7487078 100644
    --- a/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README.md	
    +++ b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README.md	
    @@ -7,7 +7,7 @@
     
     

    给你三个整数 nmk 。下图描述的算法用于找出正整数数组中最大的元素。

    -

    +![](./images/e.png)

    请你生成一个具有下述属性的数组 arr

    diff --git a/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README_EN.md b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README_EN.md index 238f88890da69..c5ae5ce8c5ebf 100644 --- a/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README_EN.md +++ b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/README_EN.md @@ -1,93 +1,145 @@ -# [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) - -[中文文档](/solution/1400-1499/1420.Build%20Array%20Where%20You%20Can%20Find%20The%20Maximum%20Exactly%20K%20Comparisons/README.md) - -## Description - -

    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
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [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) + +[中文文档](/solution/1400-1499/1420.Build%20Array%20Where%20You%20Can%20Find%20The%20Maximum%20Exactly%20K%20Comparisons/README.md) + +## Description + +

    Given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:

    + +![](./images/e.png) + +

    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
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/images/e.png b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/images/e.png new file mode 100644 index 0000000000000..da95a58c3fc31 Binary files /dev/null and b/solution/1400-1499/1420.Build Array Where You Can Find The Maximum Exactly K Comparisons/images/e.png differ diff --git a/solution/1400-1499/1424.Diagonal Traverse II/README.md b/solution/1400-1499/1424.Diagonal Traverse II/README.md index b6a7b8c4e63d4..6e3c73637f310 100644 --- a/solution/1400-1499/1424.Diagonal Traverse II/README.md +++ b/solution/1400-1499/1424.Diagonal Traverse II/README.md @@ -11,7 +11,7 @@

    示例 1:

    -

    +![](./images/sample_1_1784.png)
    输入:nums = [[1,2,3],[4,5,6],[7,8,9]]
     输出:[1,4,2,7,5,3,8,6,9]
    @@ -19,7 +19,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1784.png)
    输入:nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
     输出:[1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
    diff --git a/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md b/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md
    index 732715cb7c7b1..70c02967e8fe5 100644
    --- a/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md	
    +++ b/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md	
    @@ -8,7 +8,7 @@ Given a list of lists of integers, nums, return all eleme
     

     

    Example 1:

    -

    +![](./images/sample_1_1784.png)
     Input: nums = [[1,2,3],[4,5,6],[7,8,9]]
    @@ -17,7 +17,7 @@ Given a list of lists of integers, nums, return all eleme
     
     

    Example 2:

    -

    +![](./images/sample_2_1784.png)
     Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]
    diff --git a/solution/1400-1499/1424.Diagonal Traverse II/images/sample_1_1784.png b/solution/1400-1499/1424.Diagonal Traverse II/images/sample_1_1784.png
    new file mode 100644
    index 0000000000000..d69ba932991dc
    Binary files /dev/null and b/solution/1400-1499/1424.Diagonal Traverse II/images/sample_1_1784.png differ
    diff --git a/solution/1400-1499/1424.Diagonal Traverse II/images/sample_2_1784.png b/solution/1400-1499/1424.Diagonal Traverse II/images/sample_2_1784.png
    new file mode 100644
    index 0000000000000..df183c3dda0a9
    Binary files /dev/null and b/solution/1400-1499/1424.Diagonal Traverse II/images/sample_2_1784.png differ
    diff --git a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README.md b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README.md
    index ff2b1e481b132..ef4d8d65a7cb5 100644
    --- a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README.md	
    +++ b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README.md	
    @@ -11,7 +11,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_1_1791.png)
    输入:nums = [1,0,0,0,1,0,0,1], k = 2
     输出:true
    @@ -19,7 +19,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1791.png)
    输入:nums = [1,0,0,1,0,1], k = 2
     输出:false
    diff --git a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README_EN.md b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README_EN.md
    index abe70d97d5049..d8edffa6a8542 100644
    --- a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README_EN.md	
    +++ b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/README_EN.md	
    @@ -9,7 +9,7 @@
     

     

    Example 1:

    -

    +![](./images/sample_1_1791.png)
     Input: nums = [1,0,0,0,1,0,0,1], k = 2
    @@ -19,7 +19,7 @@
     
     

    Example 2:

    -

    +![](./images/sample_2_1791.png)
     Input: nums = [1,0,0,1,0,1], k = 2
    diff --git a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_1_1791.png b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_1_1791.png
    new file mode 100644
    index 0000000000000..cb2c951cb72a3
    Binary files /dev/null and b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_1_1791.png differ
    diff --git a/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_2_1791.png b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_2_1791.png
    new file mode 100644
    index 0000000000000..3e644f98a72d9
    Binary files /dev/null and b/solution/1400-1499/1437.Check If All 1's Are at Least Length K Places Away/images/sample_2_1791.png differ
    diff --git a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README.md b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README.md
    index 1f66d416dabcd..4f597136d3e22 100644
    --- a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README.md	
    +++ b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README.md	
    @@ -13,7 +13,7 @@
     
     

    示例 1:

    -

    +![](./images/min_time_collect_apple_1.png)
    输入:n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,true,true,false]
     输出:8 
    @@ -22,7 +22,7 @@
     
     

    示例 2:

    -

    +![](./images/min_time_collect_apple_2.png)
    输入:n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,false,true,false]
     输出:6
    diff --git a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README_EN.md b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README_EN.md
    index a6c433db1fb94..23816a68d75e7 100644
    --- a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README_EN.md	
    +++ b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/README_EN.md	
    @@ -11,7 +11,7 @@
     

     

    Example 1:

    -

    +![](./images/min_time_collect_apple_1.png)
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,true,true,false]
    @@ -21,7 +21,7 @@
     
     

    Example 2:

    -

    +![](./images/min_time_collect_apple_2.png)
     Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], hasApple = [false,false,true,false,false,true,false]
    diff --git a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_1.png b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_1.png
    new file mode 100644
    index 0000000000000..479423b2309a0
    Binary files /dev/null and b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_1.png differ
    diff --git a/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_2.png b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_2.png
    new file mode 100644
    index 0000000000000..a18be6986ba34
    Binary files /dev/null and b/solution/1400-1499/1443.Minimum Time to Collect All Apples in a Tree/images/min_time_collect_apple_2.png differ
    diff --git a/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README.md b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README.md
    index efbc21020fd65..78f37163fc7ee 100644
    --- a/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README.md	
    +++ b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/ways_to_cut_apple_1.png)
    输入:pizza = ["A..","AAA","..."], k = 3
     输出:3 
    diff --git a/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README_EN.md b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README_EN.md
    index dc5935eb53a46..7daf44542c631 100644
    --- a/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README_EN.md	
    +++ b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/README_EN.md	
    @@ -1,74 +1,108 @@
    -# [1444. Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza)
    -
    -[中文文档](/solution/1400-1499/1444.Number%20of%20Ways%20of%20Cutting%20a%20Pizza/README.md)
    -
    -## Description
    -
    -

    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.
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1444. Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza) + +[中文文档](/solution/1400-1499/1444.Number%20of%20Ways%20of%20Cutting%20a%20Pizza/README.md) + +## Description + +

    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:

    + + + +![](./images/ways_to_cut_apple_1.png) + + + +
    +
    +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.
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/images/ways_to_cut_apple_1.png b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/images/ways_to_cut_apple_1.png new file mode 100644 index 0000000000000..36c073d39826f Binary files /dev/null and b/solution/1400-1499/1444.Number of Ways of Cutting a Pizza/images/ways_to_cut_apple_1.png differ diff --git a/solution/1400-1499/1448.Count Good Nodes in Binary Tree/README.md b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/README.md index 124273060eb4b..0c6a0517f2eaa 100644 --- a/solution/1400-1499/1448.Count Good Nodes in Binary Tree/README.md +++ b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/README.md @@ -13,7 +13,7 @@

    示例 1:

    -

    +![](./images/test_sample_1.png)
    输入:root = [3,1,4,3,null,1,5]
     输出:4
    @@ -25,7 +25,7 @@
     
     

    示例 2:

    -

    +![](./images/test_sample_2.png)
    输入:root = [3,3,null,4,2]
     输出:3
    diff --git a/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_1.png b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_1.png
    new file mode 100644
    index 0000000000000..1108150d69ce1
    Binary files /dev/null and b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_1.png differ
    diff --git a/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_2.png b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_2.png
    new file mode 100644
    index 0000000000000..60a2c768cd31e
    Binary files /dev/null and b/solution/1400-1499/1448.Count Good Nodes in Binary Tree/images/test_sample_2.png differ
    diff --git a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README.md b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README.md
    index cb8f0318f184a..3ea72cefb8f8a 100644
    --- a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README.md	
    +++ b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_1_1806.png)
    输入:points = [[-2,0],[2,0],[0,2],[0,-2]], r = 2
     输出:4
    @@ -24,7 +24,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1806.png)
    输入:points = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5
     输出:5
    diff --git a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README_EN.md b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README_EN.md
    index e738e5f0348a7..a6c4a836eb039 100644
    --- a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README_EN.md	
    +++ b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/README_EN.md	
    @@ -1,81 +1,121 @@
    -# [1453. Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard)
    -
    -[中文文档](/solution/1400-1499/1453.Maximum%20Number%20of%20Darts%20Inside%20of%20a%20Circular%20Dartboard/README.md)
    -
    -## Description
    -
    -

    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
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1453. Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard) + +[中文文档](/solution/1400-1499/1453.Maximum%20Number%20of%20Darts%20Inside%20of%20a%20Circular%20Dartboard/README.md) + +## Description + +

    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:

    + + + +![](./images/sample_1_1806.png) + +
    +
    +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:

    + + + +![](./images/sample_2_1806.png) + + + +
    +
    +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
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_1_1806.png b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_1_1806.png new file mode 100644 index 0000000000000..2635756f4c40e Binary files /dev/null and b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_1_1806.png differ diff --git a/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_2_1806.png b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_2_1806.png new file mode 100644 index 0000000000000..9e4a171ffddf1 Binary files /dev/null and b/solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/images/sample_2_1806.png differ diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README.md b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README.md index d6a6cdd40e27e..57a50f14c4d96 100644 --- a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README.md +++ b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README.md @@ -13,7 +13,7 @@

    示例 1:

    -

    +![](./images/palindromic_paths_1.png)
    输入:root = [2,3,1,3,1,null,1]
     输出:2 
    @@ -23,7 +23,7 @@
     
     

    示例 2:

    -

    +![](./images/palindromic_paths_2.png)
    输入:root = [2,1,1,1,3,null,null,null,null,null,1]
     输出:1 
    diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README_EN.md b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README_EN.md
    index 814269c2f3a8b..ecac4d2705f4a 100644
    --- a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README_EN.md	
    +++ b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/README_EN.md	
    @@ -11,7 +11,8 @@
     

     

    Example 1:

    -

    + +![](./images/palindromic_paths_1.png)
     Input: root = [2,3,1,3,1,null,1]
    @@ -21,7 +22,7 @@
     
     

    Example 2:

    -

    +![](./images/palindromic_paths_2.png)
     Input: root = [2,1,1,1,3,null,null,null,null,null,1]
    diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph-1.png b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph-1.png
    new file mode 100644
    index 0000000000000..36ca79fbdfc4d
    Binary files /dev/null and b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph-1.png differ
    diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph.png b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph.png
    new file mode 100644
    index 0000000000000..1450d23be4a1c
    Binary files /dev/null and b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/graph.png differ
    diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_1.png b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_1.png
    new file mode 100644
    index 0000000000000..04ace7782c5a5
    Binary files /dev/null and b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_1.png differ
    diff --git a/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_2.png b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_2.png
    new file mode 100644
    index 0000000000000..920102d6b338d
    Binary files /dev/null and b/solution/1400-1499/1457.Pseudo-Palindromic Paths in a Binary Tree/images/palindromic_paths_2.png differ
    diff --git a/solution/1400-1499/1462.Course Schedule IV/README.md b/solution/1400-1499/1462.Course Schedule IV/README.md
    index ea9f239c82d8a..d7122c99ac40f 100644
    --- a/solution/1400-1499/1462.Course Schedule IV/README.md	
    +++ b/solution/1400-1499/1462.Course Schedule IV/README.md	
    @@ -21,7 +21,7 @@
     
     

    示例 1:

    -

    +![](./images/graph.png)
    输入:n = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
     输出:[false,true]
    @@ -37,7 +37,7 @@
     
     

    示例 3:

    -

    +![](./images/graph-1.png)
    输入:n = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
     输出:[true,true]
    diff --git a/solution/1400-1499/1462.Course Schedule IV/README_EN.md b/solution/1400-1499/1462.Course Schedule IV/README_EN.md
    index c24f556ffba31..92408e105f151 100644
    --- a/solution/1400-1499/1462.Course Schedule IV/README_EN.md	
    +++ b/solution/1400-1499/1462.Course Schedule IV/README_EN.md	
    @@ -18,7 +18,9 @@
     
     

     

    Example 1:

    - + +![](./images/graph.png) +
     Input: n = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
     Output: [false,true]
    @@ -34,7 +36,9 @@
     

    Example 3:

    - + +![](./images/graph-1.png) +
     Input: n = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
     Output: [true,true]
    diff --git a/solution/1400-1499/1463.Cherry Pickup II/README.md b/solution/1400-1499/1463.Cherry Pickup II/README.md
    index 389e33ea3aa47..59c0002f3bbc4 100644
    --- a/solution/1400-1499/1463.Cherry Pickup II/README.md	
    +++ b/solution/1400-1499/1463.Cherry Pickup II/README.md	
    @@ -23,7 +23,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_1_1802.png)
    输入:grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
     输出:24
    @@ -35,7 +35,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1802.png)
    输入: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]]
     输出:28
    diff --git a/solution/1400-1499/1463.Cherry Pickup II/README_EN.md b/solution/1400-1499/1463.Cherry Pickup II/README_EN.md
    index 4029c34329763..213f3ec8d3d8d 100644
    --- a/solution/1400-1499/1463.Cherry Pickup II/README_EN.md	
    +++ b/solution/1400-1499/1463.Cherry Pickup II/README_EN.md	
    @@ -21,7 +21,8 @@
     

     

    Example 1:

    -

    +![](./images/sample_1_1802.png) +
     Input: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]
    @@ -34,7 +35,7 @@ Total of cherries: 12 + 12 = 24.
     
     

    Example 2:

    -

    +![](./images/sample_2_1802.png)
     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]]
    diff --git a/solution/1400-1499/1463.Cherry Pickup II/images/sample_1_1802.png b/solution/1400-1499/1463.Cherry Pickup II/images/sample_1_1802.png
    new file mode 100644
    index 0000000000000..e42fdaabfad6f
    Binary files /dev/null and b/solution/1400-1499/1463.Cherry Pickup II/images/sample_1_1802.png differ
    diff --git a/solution/1400-1499/1463.Cherry Pickup II/images/sample_2_1802.png b/solution/1400-1499/1463.Cherry Pickup II/images/sample_2_1802.png
    new file mode 100644
    index 0000000000000..e739bb54ec6a5
    Binary files /dev/null and b/solution/1400-1499/1463.Cherry Pickup II/images/sample_2_1802.png differ
    diff --git a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README.md b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README.md
    index 301ea27384351..22902ad163307 100644
    --- a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README.md	
    +++ b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README.md	
    @@ -13,7 +13,7 @@
     
     

    示例 1:

    -

    +![](./images/leetcode_max_area_2.png)
    输入:h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]
     输出:4 
    @@ -22,7 +22,7 @@
     
     

    示例 2:

    -

    +![](./images/leetcode_max_area_3.png)
    输入:h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]
     输出:6
    diff --git a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README_EN.md b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README_EN.md
    index eb14e0ad8ec74..0594c4f90c63f 100644
    --- a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README_EN.md	
    +++ b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/README_EN.md	
    @@ -11,7 +11,7 @@
     

     

    Example 1:

    -

    +![](./images/leetcode_max_area_2.png)
     Input: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]
    @@ -21,7 +21,7 @@
     
     

    Example 2:

    -

    +![](./images/leetcode_max_area_3.png)
     Input: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]
    diff --git a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_2.png b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_2.png
    new file mode 100644
    index 0000000000000..40f50a6b6d2be
    Binary files /dev/null and b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_2.png differ
    diff --git a/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_3.png b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_3.png
    new file mode 100644
    index 0000000000000..6aafa986f6a90
    Binary files /dev/null and b/solution/1400-1499/1465.Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts/images/leetcode_max_area_3.png differ
    diff --git a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README.md b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README.md
    index 3b994721d447e..d13b39b64e176 100644
    --- a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README.md	
    +++ b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README.md	
    @@ -19,7 +19,8 @@
     
     

    示例 1:

    -

    + +![](./images/sample_1_1819.png)
    输入:n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]
     输出:3
    @@ -27,7 +28,8 @@
     
     

    示例 2:

    -

    + +![](./images/sample_2_1819.png)
    输入:n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]
     输出:2
    diff --git a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README_EN.md b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README_EN.md
    index 83152de01a9a9..cbf55fcfbb9b2 100644
    --- a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README_EN.md	
    +++ b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/README_EN.md	
    @@ -17,7 +17,7 @@
     

     

    Example 1:

    -

    +![](./images/sample_1_1819.png)
     Input: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]
    @@ -26,7 +26,7 @@
     
     

    Example 2:

    -

    +![](./images/sample_2_1819.png)
     Input: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]
    diff --git a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_1_1819.png b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_1_1819.png
    new file mode 100644
    index 0000000000000..8e85ba0572bba
    Binary files /dev/null and b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_1_1819.png differ
    diff --git a/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_2_1819.png b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_2_1819.png
    new file mode 100644
    index 0000000000000..8fdc705d83206
    Binary files /dev/null and b/solution/1400-1499/1466.Reorder Routes to Make All Paths Lead to the City Zero/images/sample_2_1819.png differ
    diff --git a/solution/1400-1499/1478.Allocate Mailboxes/README.md b/solution/1400-1499/1478.Allocate Mailboxes/README.md
    index 1453f349dc25f..cb9599fa7faa9 100644
    --- a/solution/1400-1499/1478.Allocate Mailboxes/README.md	
    +++ b/solution/1400-1499/1478.Allocate Mailboxes/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_11_1816.png)
    输入:houses = [1,4,8,10,20], k = 3
     输出:5
    @@ -25,7 +25,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1816.png)
    输入:houses = [2,3,5,12,18], k = 2
     输出:9
    diff --git a/solution/1400-1499/1478.Allocate Mailboxes/README_EN.md b/solution/1400-1499/1478.Allocate Mailboxes/README_EN.md
    index 44dbf31f9bcdb..34a7fb086bc5e 100644
    --- a/solution/1400-1499/1478.Allocate Mailboxes/README_EN.md	
    +++ b/solution/1400-1499/1478.Allocate Mailboxes/README_EN.md	
    @@ -1,86 +1,129 @@
    -# [1478. Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes)
    -
    -[中文文档](/solution/1400-1499/1478.Allocate%20Mailboxes/README.md)
    -
    -## Description
    -
    -

    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.
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1478. Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes) + +[中文文档](/solution/1400-1499/1478.Allocate%20Mailboxes/README.md) + +## Description + +

    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:

    + + + +![](./images/sample_11_1816.png) + +
    +
    +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:

    + + + +![](./images/sample_2_1816.png) + + +
    +
    +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.
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1400-1499/1478.Allocate Mailboxes/images/sample_11_1816.png b/solution/1400-1499/1478.Allocate Mailboxes/images/sample_11_1816.png new file mode 100644 index 0000000000000..7f0a210770311 Binary files /dev/null and b/solution/1400-1499/1478.Allocate Mailboxes/images/sample_11_1816.png differ diff --git a/solution/1400-1499/1478.Allocate Mailboxes/images/sample_2_1816.png b/solution/1400-1499/1478.Allocate Mailboxes/images/sample_2_1816.png new file mode 100644 index 0000000000000..a45a61c1a7cf6 Binary files /dev/null and b/solution/1400-1499/1478.Allocate Mailboxes/images/sample_2_1816.png differ diff --git a/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README.md b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README.md index d392234471bce..4037ffee449d7 100644 --- a/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README.md +++ b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README.md @@ -15,7 +15,8 @@

    示例:

    -

    + +![](./images/1528_ex1.png)
    输入:
     ["TreeAncestor","getKthAncestor","getKthAncestor","getKthAncestor"]
    diff --git a/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README_EN.md b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README_EN.md
    index b34fc673c83ba..64e5ce5238d5e 100644
    --- a/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README_EN.md	
    +++ b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/README_EN.md	
    @@ -1,71 +1,100 @@
    -# [1483. Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node)
    -
    -[中文文档](/solution/1400-1499/1483.Kth%20Ancestor%20of%20a%20Tree%20Node/README.md)
    -
    -## Description
    -
    -

    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.
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1483. Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node) + +[中文文档](/solution/1400-1499/1483.Kth%20Ancestor%20of%20a%20Tree%20Node/README.md) + +## Description + +

    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:

    + + +![](./images/1528_ex1.png) + + +
    +
    +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.
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1400-1499/1483.Kth Ancestor of a Tree Node/images/1528_ex1.png b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/images/1528_ex1.png new file mode 100644 index 0000000000000..3f585103ab759 Binary files /dev/null and b/solution/1400-1499/1483.Kth Ancestor of a Tree Node/images/1528_ex1.png differ diff --git a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README.md b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README.md index cf63b68b51558..45622f0dbd2fb 100644 --- a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README.md +++ b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README.md @@ -15,20 +15,22 @@

    示例 1:

    -

    +![](./images/ex1.png)
    输入:n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]
     输出:[[0,1],[2,3,4,5]]
     解释:上图描述了给定图。
     下图是所有的最小生成树。
    -
    +
    +![](./images/msts.png)
    +
     注意到第 0 条边和第 1 条边出现在了所有最小生成树中,所以它们是关键边,我们将这两个下标作为输出的第一个列表。
     边 2,3,4 和 5 是所有 MST 的剩余边,所以它们是伪关键边。我们将它们作为输出的第二个列表。
     

    示例 2 :

    -

    +![](./images/ex2.png)
    输入:n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]
     输出:[[],[0,1,2,3]]
    diff --git a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README_EN.md b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README_EN.md
    index 2af4bb613c473..a4a9ad01c3ab8 100644
    --- a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README_EN.md	
    +++ b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/README_EN.md	
    @@ -13,21 +13,23 @@
     

     

    Example 1:

    -

    +![](./images/ex1.png)
     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:
    -
    +
    +![](./images/msts.png)
    +
     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:

    -

    +![](./images/ex2.png)
     Input: n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]
    diff --git a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex1.png b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex1.png
    new file mode 100644
    index 0000000000000..16da074c089c6
    Binary files /dev/null and b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex1.png differ
    diff --git a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex2.png b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex2.png
    new file mode 100644
    index 0000000000000..65a2fddac3dcb
    Binary files /dev/null and b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/ex2.png differ
    diff --git a/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/msts.png b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/msts.png
    new file mode 100644
    index 0000000000000..5b32a6c762dee
    Binary files /dev/null and b/solution/1400-1499/1489.Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree/images/msts.png differ
    diff --git a/solution/1400-1499/1494.Parallel Courses II/README.md b/solution/1400-1499/1494.Parallel Courses II/README.md
    index 952c40f68802b..3d15b8068f7e7 100644
    --- a/solution/1400-1499/1494.Parallel Courses II/README.md	
    +++ b/solution/1400-1499/1494.Parallel Courses II/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/leetcode_parallel_courses_1.png)
    输入:n = 4, dependencies = [[2,1],[3,1],[1,4]], k = 2
     输出:3 
    @@ -24,7 +24,7 @@
     
     

    示例 2:

    -

    +![](./images/leetcode_parallel_courses_2.png)
    输入:n = 5, dependencies = [[2,1],[3,1],[4,1],[1,5]], k = 2
     输出:4 
    diff --git a/solution/1400-1499/1494.Parallel Courses II/README_EN.md b/solution/1400-1499/1494.Parallel Courses II/README_EN.md
    index 9b37ca13359d5..bb308475a91d8 100644
    --- a/solution/1400-1499/1494.Parallel Courses II/README_EN.md	
    +++ b/solution/1400-1499/1494.Parallel Courses II/README_EN.md	
    @@ -13,7 +13,7 @@
     

     

    Example 1:

    -

    +![](./images/leetcode_parallel_courses_1.png)
     Input: n = 4, dependencies = [[2,1],[3,1],[1,4]], k = 2
    @@ -23,7 +23,7 @@
     
     

    Example 2:

    -

    +![](./images/leetcode_parallel_courses_2.png)
     Input: n = 5, dependencies = [[2,1],[3,1],[4,1],[1,5]], k = 2
    diff --git a/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_1.png b/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_1.png
    new file mode 100644
    index 0000000000000..f7d22ac6ccb9d
    Binary files /dev/null and b/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_1.png differ
    diff --git a/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_2.png b/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_2.png
    new file mode 100644
    index 0000000000000..becf74ad92732
    Binary files /dev/null and b/solution/1400-1499/1494.Parallel Courses II/images/leetcode_parallel_courses_2.png differ
    diff --git a/solution/1400-1499/1496.Path Crossing/README.md b/solution/1400-1499/1496.Path Crossing/README.md
    index 947d4fde3839f..a4f201b38735a 100644
    --- a/solution/1400-1499/1496.Path Crossing/README.md	
    +++ b/solution/1400-1499/1496.Path Crossing/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/screen-shot-2020-06-10-at-123929-pm.png)
    输入:path = "NES"
     输出:false 
    @@ -23,7 +23,7 @@
     
     

    示例 2:

    -

    +![](./images/screen-shot-2020-06-10-at-123843-pm.png)
    输入:path = "NESWW"
     输出:true
    diff --git a/solution/1400-1499/1496.Path Crossing/README_EN.md b/solution/1400-1499/1496.Path Crossing/README_EN.md
    index 2ae11847ee5f9..b088da15b702b 100644
    --- a/solution/1400-1499/1496.Path Crossing/README_EN.md	
    +++ b/solution/1400-1499/1496.Path Crossing/README_EN.md	
    @@ -11,7 +11,7 @@
     

     

    Example 1:

    -

    +![](./images/screen-shot-2020-06-10-at-123929-pm.png)
     Input: path = "NES"
    @@ -21,7 +21,7 @@
     
     

    Example 2:

    -

    +![](./images/screen-shot-2020-06-10-at-123843-pm.png)
     Input: path = "NESWW"
    diff --git a/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123843-pm.png b/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123843-pm.png
    new file mode 100644
    index 0000000000000..56abe17d24abf
    Binary files /dev/null and b/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123843-pm.png differ
    diff --git a/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123929-pm.png b/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123929-pm.png
    new file mode 100644
    index 0000000000000..4eb8c79a1afa8
    Binary files /dev/null and b/solution/1400-1499/1496.Path Crossing/images/screen-shot-2020-06-10-at-123929-pm.png differ
    diff --git a/solution/1500-1599/1514.Path with Maximum Probability/README.md b/solution/1500-1599/1514.Path with Maximum Probability/README.md
    index f4d6bd8755e42..6135822b1f708 100644
    --- a/solution/1500-1599/1514.Path with Maximum Probability/README.md	
    +++ b/solution/1500-1599/1514.Path with Maximum Probability/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/1558_ex1.png)
    输入:n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.2], start = 0, end = 2
     输出:0.25000
    @@ -24,7 +24,7 @@
     
     

    示例 2:

    -

    +![](./images/1558_ex2.png)
    输入:n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.3], start = 0, end = 2
     输出:0.30000
    @@ -32,7 +32,7 @@
     
     

    示例 3:

    -

    +![](./images/1558_ex3.png)
    输入:n = 3, edges = [[0,1]], succProb = [0.5], start = 0, end = 2
     输出:0.00000
    diff --git a/solution/1500-1599/1514.Path with Maximum Probability/README_EN.md b/solution/1500-1599/1514.Path with Maximum Probability/README_EN.md
    index 71ac97bbdea12..60889a8ab0182 100644
    --- a/solution/1500-1599/1514.Path with Maximum Probability/README_EN.md	
    +++ b/solution/1500-1599/1514.Path with Maximum Probability/README_EN.md	
    @@ -1,82 +1,118 @@
    -# [1514. Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability)
    -
    -[中文文档](/solution/1500-1599/1514.Path%20with%20Maximum%20Probability/README.md)
    -
    -## Description
    -
    -

    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.
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1514. Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability) + +[中文文档](/solution/1500-1599/1514.Path%20with%20Maximum%20Probability/README.md) + +## Description + +

    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:

    + + + +![](./images/1558_ex1.png) + + +
    +
    +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:

    + + + +![](./images/1558_ex2.png) + + +
    +
    +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:

    + + + +![](./images/1558_ex3.png) + + +
    +
    +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.
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex1.png b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex1.png new file mode 100644 index 0000000000000..bf7705f2935b9 Binary files /dev/null and b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex1.png differ diff --git a/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex2.png b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex2.png new file mode 100644 index 0000000000000..89b1fc9d15127 Binary files /dev/null and b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex2.png differ diff --git a/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex3.png b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex3.png new file mode 100644 index 0000000000000..a97890611bc94 Binary files /dev/null and b/solution/1500-1599/1514.Path with Maximum Probability/images/1558_ex3.png differ diff --git a/solution/1500-1599/1515.Best Position for a Service Centre/README.md b/solution/1500-1599/1515.Best Position for a Service Centre/README.md index 2f2e02cdc249d..05d220fb05f9c 100644 --- a/solution/1500-1599/1515.Best Position for a Service Centre/README.md +++ b/solution/1500-1599/1515.Best Position for a Service Centre/README.md @@ -11,7 +11,7 @@

    换句话说,请你为服务中心选址,该位置的坐标 [xcentre, ycentre] 需要使下面的公式取到最小值:

    -

    +![](./images/q4_edited.jpg)

    与真实值误差在 10^-5 之内的答案将被视作正确答案。

    @@ -19,7 +19,7 @@

    示例 1:

    -

    +![](./images/q4_e1.jpg)
    输入:positions = [[0,1],[1,0],[1,2],[2,1]]
     输出:4.00000
    @@ -28,7 +28,7 @@
     
     

    示例 2:

    -

    +![](./images/q4_e3.jpg)
    输入:positions = [[1,1],[3,3]]
     输出:2.82843
    diff --git a/solution/1500-1599/1515.Best Position for a Service Centre/README_EN.md b/solution/1500-1599/1515.Best Position for a Service Centre/README_EN.md
    index 56c30cd4dd74c..26f3d7ed6c4f1 100644
    --- a/solution/1500-1599/1515.Best Position for a Service Centre/README_EN.md	
    +++ b/solution/1500-1599/1515.Best Position for a Service Centre/README_EN.md	
    @@ -9,12 +9,16 @@
     

    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:

    - + +![](./images/q4_edited.jpg) +

    Answers within 10^-5 of the actual value will be accepted.

     

    Example 1:

    - + +![](./images/q4_e1.jpg) +
     Input: positions = [[0,1],[1,0],[1,2],[2,1]]
     Output: 4.00000
    @@ -22,7 +26,9 @@
     

    Example 2:

    - + +![](./images/q4_e3.jpg) +
     Input: positions = [[1,1],[3,3]]
     Output: 2.82843
    diff --git a/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e1.jpg b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e1.jpg
    new file mode 100644
    index 0000000000000..9295ef0001299
    Binary files /dev/null and b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e1.jpg differ
    diff --git a/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e3.jpg b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e3.jpg
    new file mode 100644
    index 0000000000000..0cc5227ff7f29
    Binary files /dev/null and b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_e3.jpg differ
    diff --git a/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_edited.jpg b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_edited.jpg
    new file mode 100644
    index 0000000000000..dfe3eb5867ce5
    Binary files /dev/null and b/solution/1500-1599/1515.Best Position for a Service Centre/images/q4_edited.jpg differ
    diff --git a/solution/1500-1599/1518.Water Bottles/README.md b/solution/1500-1599/1518.Water Bottles/README.md
    index 84c964a254b9d..2e05509355191 100644
    --- a/solution/1500-1599/1518.Water Bottles/README.md	
    +++ b/solution/1500-1599/1518.Water Bottles/README.md	
    @@ -15,7 +15,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_1_1875.png)
    输入:numBottles = 9, numExchange = 3
     输出:13
    @@ -25,7 +25,7 @@
     
     

    示例 2:

    -

    +![](./images/sample_2_1875.png)
    输入:numBottles = 15, numExchange = 4
     输出:19
    diff --git a/solution/1500-1599/1518.Water Bottles/images/sample_1_1875.png b/solution/1500-1599/1518.Water Bottles/images/sample_1_1875.png
    new file mode 100644
    index 0000000000000..aab02d3db089c
    Binary files /dev/null and b/solution/1500-1599/1518.Water Bottles/images/sample_1_1875.png differ
    diff --git a/solution/1500-1599/1518.Water Bottles/images/sample_2_1875.png b/solution/1500-1599/1518.Water Bottles/images/sample_2_1875.png
    new file mode 100644
    index 0000000000000..2c9a40997f8ff
    Binary files /dev/null and b/solution/1500-1599/1518.Water Bottles/images/sample_2_1875.png differ
    diff --git a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README.md b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README.md
    index cc54722a9f40b..5ec3d0dcc41ea 100644
    --- a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README.md	
    +++ b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README.md	
    @@ -17,7 +17,7 @@
     
     

    示例 1:

    -

    +![](./images/q3e1.jpg)
    输入:n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = "abaedcd"
     输出:[2,1,1,1,1,1,1]
    @@ -27,7 +27,7 @@
     
     

    示例 2:

    -

    +![](./images/q3e2.jpg)
    输入:n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
     输出:[4,2,1,1]
    @@ -39,7 +39,7 @@
     
     

    示例 3:

    -

    +![](./images/q3e3.jpg)
    输入:n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
     输出:[3,2,1,1,1]
    diff --git a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README_EN.md b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README_EN.md
    index d9a10cc7d3f2c..e66296dde5f64 100644
    --- a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README_EN.md	
    +++ b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/README_EN.md	
    @@ -14,7 +14,9 @@
     
     

     

    Example 1:

    - + +![](./images/q3e1.jpg) +
     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]
    @@ -23,7 +25,9 @@ Node 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5,
     

    Example 2:

    - + +![](./images/q3e2.jpg) +
     Input: n = 4, edges = [[0,1],[1,2],[0,3]], labels = "bbbb"
     Output: [4,2,1,1]
    @@ -34,7 +38,9 @@ The sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b',
     

    Example 3:

    - + +![](./images/q3e3.jpg) +
     Input: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = "aabab"
     Output: [3,2,1,1,1]
    diff --git a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e1.jpg b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e1.jpg
    new file mode 100644
    index 0000000000000..0e12a06f3bde7
    Binary files /dev/null and b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e1.jpg differ
    diff --git a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e2.jpg b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e2.jpg
    new file mode 100644
    index 0000000000000..1f00a12806f6e
    Binary files /dev/null and b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e2.jpg differ
    diff --git a/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e3.jpg b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e3.jpg
    new file mode 100644
    index 0000000000000..508ac40e21da9
    Binary files /dev/null and b/solution/1500-1599/1519.Number of Nodes in the Sub-Tree With the Same Label/images/q3e3.jpg differ
    diff --git a/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README.md b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README.md
    index d32242aa92b91..2056cbc420b6d 100644
    --- a/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README.md	
    +++ b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README.md	
    @@ -5,7 +5,8 @@
     ## 题目描述
     
     
    -

    + +![](./images/change.png)

    Winston 构造了一个如上所示的函数 func 。他有一个整数数组 arr 和一个整数 target ,他想找到让 |func(arr, l, r) - target| 最小的 l 和 r 。

    diff --git a/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README_EN.md b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README_EN.md index 3ee9f09cc1237..e975bacac35e0 100644 --- a/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README_EN.md +++ b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/README_EN.md @@ -4,7 +4,7 @@ ## Description -

    +![](./images/change.png)

    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.

    diff --git a/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/images/change.png b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/images/change.png new file mode 100644 index 0000000000000..07a9b5cfd8a90 Binary files /dev/null and b/solution/1500-1599/1521.Find a Value of a Mysterious Function Closest to Target/images/change.png differ diff --git a/solution/1500-1599/1528.Shuffle String/README.md b/solution/1500-1599/1528.Shuffle String/README.md index b6eb799951eb6..8c3c3ab9d6055 100644 --- a/solution/1500-1599/1528.Shuffle String/README.md +++ b/solution/1500-1599/1528.Shuffle String/README.md @@ -15,7 +15,7 @@

    示例 1:

    -

    +![](./images/q1.jpg)
    输入:s = "codeleet", indices = [4,5,6,7,0,2,1,3]
     输出:"leetcode"
    diff --git a/solution/1500-1599/1528.Shuffle String/README_EN.md b/solution/1500-1599/1528.Shuffle String/README_EN.md
    index bb68f15281c6e..ea2def5c5d5da 100644
    --- a/solution/1500-1599/1528.Shuffle String/README_EN.md	
    +++ b/solution/1500-1599/1528.Shuffle String/README_EN.md	
    @@ -1,87 +1,134 @@
    -# [1528. Shuffle String](https://leetcode.com/problems/shuffle-string)
    -
    -[中文文档](/solution/1500-1599/1528.Shuffle%20String/README.md)
    -
    -## Description
    -
    -

    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).
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1528. Shuffle String](https://leetcode.com/problems/shuffle-string) + +[中文文档](/solution/1500-1599/1528.Shuffle%20String/README.md) + +## Description + +

    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:

    + +![](./images/q1.jpg) + +
    +
    +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).
    • +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1500-1599/1528.Shuffle String/images/q1.jpg b/solution/1500-1599/1528.Shuffle String/images/q1.jpg new file mode 100644 index 0000000000000..19a965806f8c9 Binary files /dev/null and b/solution/1500-1599/1528.Shuffle String/images/q1.jpg differ diff --git a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README.md b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README.md index b0f5b6d753f57..abd25a2a71a50 100644 --- a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README.md +++ b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README.md @@ -17,7 +17,7 @@

     

    -

    +![](./images/e1.jpg)
    输入:root = [1,2,3,null,4], distance = 3
     输出:1
    @@ -26,7 +26,7 @@
     
     

    示例 2:

    -

    +![](./images/e2.jpg)
    输入:root = [1,2,3,4,5,6,7], distance = 3
     输出:2
    diff --git a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README_EN.md b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README_EN.md
    index 39fbfe7fe0374..d256e4cf1599f 100644
    --- a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README_EN.md	
    +++ b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/README_EN.md	
    @@ -1,84 +1,134 @@
    -# [1530. Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs)
    -
    -[中文文档](/solution/1500-1599/1530.Number%20of%20Good%20Leaf%20Nodes%20Pairs/README.md)
    -
    -## Description
    -
    -

    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
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1530. Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs) + +[中文文档](/solution/1500-1599/1530.Number%20of%20Good%20Leaf%20Nodes%20Pairs/README.md) + +## Description + +

    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:

    + +![](./images/e1.jpg) + +
    +
    +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:

    + +![](./images/e2.jpg) + +
    +
    +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
    • + +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e1.jpg b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e1.jpg new file mode 100644 index 0000000000000..1040880d4b46b Binary files /dev/null and b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e1.jpg differ diff --git a/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e2.jpg b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e2.jpg new file mode 100644 index 0000000000000..4d6f04c55baf8 Binary files /dev/null and b/solution/1500-1599/1530.Number of Good Leaf Nodes Pairs/images/e2.jpg differ diff --git a/solution/1500-1599/1535.Find the Winner of an Array Game/README.md b/solution/1500-1599/1535.Find the Winner of an Array Game/README.md index 7e92cfb8763e4..b89f4cb5b446c 100644 --- a/solution/1500-1599/1535.Find the Winner of an Array Game/README.md +++ b/solution/1500-1599/1535.Find the Winner of an Array Game/README.md @@ -20,7 +20,9 @@
    输入:arr = [2,1,3,5,4,6,7], k = 2
     输出:5
     解释:一起看一下本场游戏每回合的情况:
    -
    +
    +![](./images/q-example.png)
    +
     因此将进行 4 回合比赛,其中 5 是赢家,因为它连胜 2 回合。
     
    diff --git a/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md b/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md index 165bdce42ae8d..a4015014a046f 100644 --- a/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md +++ b/solution/1500-1599/1535.Find the Winner of an Array Game/README_EN.md @@ -1,87 +1,136 @@ -# [1535. Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game) - -[中文文档](/solution/1500-1599/1535.Find%20the%20Winner%20of%20an%20Array%20Game/README.md) - -## Description - -

    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
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1535. Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game) + +[中文文档](/solution/1500-1599/1535.Find%20the%20Winner%20of%20an%20Array%20Game/README.md) + +## Description + +

    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
    • + +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1500-1599/1535.Find the Winner of an Array Game/images/q-example.png b/solution/1500-1599/1535.Find the Winner of an Array Game/images/q-example.png new file mode 100644 index 0000000000000..155c11e9d9c9b Binary files /dev/null and b/solution/1500-1599/1535.Find the Winner of an Array Game/images/q-example.png differ diff --git a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README.md b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README.md index 12e6b4c1a8d4f..7982a6d225586 100644 --- a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README.md +++ b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README.md @@ -17,7 +17,7 @@

    示例 1:

    -

    +![](./images/fw.jpg)
    输入:grid = [[0,0,1],[1,1,0],[1,0,0]]
     输出:3
    @@ -25,7 +25,7 @@
     
     

    示例 2:

    -

    +![](./images/e2.jpg)
    输入:grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]
     输出:-1
    @@ -34,7 +34,7 @@
     
     

    示例 3:

    -

    +![](./images/e3.jpg)
    输入:grid = [[1,0,0],[1,1,0],[1,1,1]]
     输出:0
    diff --git a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README_EN.md b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README_EN.md
    index 8e53609ed0f89..3f8c5d84a37f9 100644
    --- a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README_EN.md	
    +++ b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/README_EN.md	
    @@ -14,14 +14,18 @@
     
     

     

    Example 1:

    - + +![](./images/fw.jpg) +
     Input: grid = [[0,0,1],[1,1,0],[1,0,0]]
     Output: 3
     

    Example 2:

    - + +![](./images/e2.jpg) +
     Input: grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]
     Output: -1
    @@ -29,7 +33,9 @@
     

    Example 3:

    - + +![](./images/e3.jpg) +
     Input: grid = [[1,0,0],[1,1,0],[1,1,1]]
     Output: 0
    diff --git a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e2.jpg b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e2.jpg
    new file mode 100644
    index 0000000000000..5c6c983f78981
    Binary files /dev/null and b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e2.jpg differ
    diff --git a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e3.jpg b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e3.jpg
    new file mode 100644
    index 0000000000000..3e83e583ea174
    Binary files /dev/null and b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/e3.jpg differ
    diff --git a/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/fw.jpg b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/fw.jpg
    new file mode 100644
    index 0000000000000..0b432f527d53d
    Binary files /dev/null and b/solution/1500-1599/1536.Minimum Swaps to Arrange a Binary Grid/images/fw.jpg differ
    diff --git a/solution/1500-1599/1537.Get the Maximum Score/README.md b/solution/1500-1599/1537.Get the Maximum Score/README.md
    index 5d998c1bb1bdb..c3387e57b80c0 100644
    --- a/solution/1500-1599/1537.Get the Maximum Score/README.md	
    +++ b/solution/1500-1599/1537.Get the Maximum Score/README.md	
    @@ -25,7 +25,7 @@
     
     

    示例 1:

    -

    +![](./images/sample_1_1893.png)
    输入:nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
     输出:30
    diff --git a/solution/1500-1599/1537.Get the Maximum Score/README_EN.md b/solution/1500-1599/1537.Get the Maximum Score/README_EN.md
    index f8511e33140c3..14bb69957fc7d 100644
    --- a/solution/1500-1599/1537.Get the Maximum Score/README_EN.md	
    +++ b/solution/1500-1599/1537.Get the Maximum Score/README_EN.md	
    @@ -23,7 +23,7 @@
     

     

    Example 1:

    -

    +![](./images/sample_1_1893.png)
     Input: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
    diff --git a/solution/1500-1599/1537.Get the Maximum Score/images/sample_1_1893.png b/solution/1500-1599/1537.Get the Maximum Score/images/sample_1_1893.png
    new file mode 100644
    index 0000000000000..75f16fc7ed3c5
    Binary files /dev/null and b/solution/1500-1599/1537.Get the Maximum Score/images/sample_1_1893.png differ
    diff --git a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README.md b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README.md
    index 7b3b414927f97..33e5048abc9f0 100644
    --- a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README.md	
    +++ b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README.md	
    @@ -7,7 +7,7 @@
     
     

    有一根长度为 n 个单位的木棍,棍上从 0n 标记了若干位置。例如,长度为 6 的棍子可以标记如下:

    -

    +![](./images/statement.jpg)

    给你一个整数数组 cuts ,其中 cuts[i] 表示你需要将棍子切开的位置。

    @@ -21,12 +21,14 @@

    示例 1:

    -

    +![](./images/e1.jpg)
    输入:n = 7, cuts = [1,3,4,5]
     输出:16
     解释:按 [1, 3, 4, 5] 的顺序切割的情况如下所示:
    -
    +
    +![](./images/e11.jpg)
    +
     第一次切割长度为 7 的棍子,成本为 7 。第二次切割长度为 6 的棍子(即第一次切割得到的第二根棍子),第三次切割为长度 4 的棍子,最后切割长度为 3 的棍子。总成本为 7 + 6 + 4 + 3 = 20 。
     而将切割顺序重新排列为 [3, 5, 1, 4] 后,总成本 = 16(如示例图中 7 + 4 + 3 + 2 = 16)。
     
    diff --git a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README_EN.md b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README_EN.md index f57d59162c7fa..fb0bd06c5d9f0 100644 --- a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README_EN.md +++ b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/README_EN.md @@ -1,72 +1,110 @@ -# [1547. Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick) - -[中文文档](/solution/1500-1599/1547.Minimum%20Cost%20to%20Cut%20a%20Stick/README.md) - -## Description - -

    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.
    • -
    - -## Solutions - - - - - -### **Python3** - - -```python - -``` - -### **Java** - - -```java - -``` - -### **...** -``` - -``` - +# [1547. Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick) + +[中文文档](/solution/1500-1599/1547.Minimum%20Cost%20to%20Cut%20a%20Stick/README.md) + +## Description + +

    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:

    + +![](./images/statement.jpg) + +

    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:

    + +![](./images/e1.jpg) + +
    +
    +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:
    +
    +![](./images/e11.jpg)
    +
    +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.
    • + +
    + +## Solutions + + + + + +### **Python3** + + +```python + +``` + +### **Java** + + +```java + +``` + +### **...** +``` + +``` + \ No newline at end of file diff --git a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e1.jpg b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e1.jpg new file mode 100644 index 0000000000000..ff7f456d2d0c0 Binary files /dev/null and b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e1.jpg differ diff --git a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e11.jpg b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e11.jpg new file mode 100644 index 0000000000000..77deeed64d110 Binary files /dev/null and b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/e11.jpg differ diff --git a/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/statement.jpg b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/statement.jpg new file mode 100644 index 0000000000000..70e9b58c7221b Binary files /dev/null and b/solution/1500-1599/1547.Minimum Cost to Cut a Stick/images/statement.jpg differ diff --git a/solution/1500-1599/1552.Magnetic Force Between Two Balls/README.md b/solution/1500-1599/1552.Magnetic Force Between Two Balls/README.md index 2f6a9d6241381..bc6d755baf52f 100644 --- a/solution/1500-1599/1552.Magnetic Force Between Two Balls/README.md +++ b/solution/1500-1599/1552.Magnetic Force Between Two Balls/README.md @@ -15,7 +15,7 @@

    示例 1:

    -

    +![](./images/q3v1.jpg)
    输入:position = [1,2,3,4,7], m = 3
     输出:3
    diff --git a/solution/1500-1599/1552.Magnetic Force Between Two Balls/README_EN.md b/solution/1500-1599/1552.Magnetic Force Between Two Balls/README_EN.md
    index 4e7ab40a8cdd7..d1df4cc9ea413 100644
    --- a/solution/1500-1599/1552.Magnetic Force Between Two Balls/README_EN.md	
    +++ b/solution/1500-1599/1552.Magnetic Force Between Two Balls/README_EN.md	
    @@ -12,7 +12,9 @@
     
     

     

    Example 1:

    - + +![](./images/q3v1.jpg) +
     Input: position = [1,2,3,4,7], m = 3
     Output: 3
    diff --git a/solution/1500-1599/1552.Magnetic Force Between Two Balls/images/q3v1.jpg b/solution/1500-1599/1552.Magnetic Force Between Two Balls/images/q3v1.jpg
    new file mode 100644
    index 0000000000000..a81c0ebb0eabf
    Binary files /dev/null and b/solution/1500-1599/1552.Magnetic Force Between Two Balls/images/q3v1.jpg differ