Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5e5f55

Browse files
feat: add solutions to lc problems: No.3383,3384 (doocs#3850)
1 parent ff32fdd commit e5e5f55

File tree

24 files changed

+1620
-17
lines changed

24 files changed

+1620
-17
lines changed

‎solution/1800-1899/1812.Determine Color of a Chessboard Square/README.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ tags:
7272

7373
观察棋盘我们发现,颜色相同的两个格子 $(x_1, y_1)$ 和 $(x_2, y_2)$ 满足 $x_1 + y_1$ 和 $x_2 + y_2$ 均为奇数或偶数。
7474

75-
因此,我们可以根据 `coordinates` 获取对应的坐标 $(x, y),ドル如果 $x + y$ 为奇数,则格子为白色,返回 `true`,否则返回 `false`
75+
因此,我们可以根据 $\textit{coordinates}$ 获取对应的坐标 $(x, y),ドル如果 $x + y$ 为奇数,则格子为白色,返回 $\textit{true}$,否则返回 $\textit{false}$
7676

7777
时间复杂度 $O(1),ドル空间复杂度 $O(1)$。
7878

@@ -142,9 +142,7 @@ impl Solution {
142142
* @return {boolean}
143143
*/
144144
var squareIsWhite = function (coordinates) {
145-
const x = coordinates.charAt(0).charCodeAt();
146-
const y = coordinates.charAt(1).charCodeAt();
147-
return (x + y) % 2 == 1;
145+
return (coordinates[0].charCodeAt() + coordinates[1].charCodeAt()) % 2 == 1;
148146
};
149147
```
150148

‎solution/1800-1899/1812.Determine Color of a Chessboard Square/README_EN.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ tags:
6666

6767
<!-- solution:start -->
6868

69-
### Solution 1: Find the Pattern
69+
### Solution 1: Pattern Recognition
7070

71-
By observing the chessboard, we find that two squares $(x_1, y_1)$ and $(x_2, y_2)$ with the same color satisfy that both $x_1 + y_1$ and $x_2 + y_2$ are either odd or even.
71+
Observing the chessboard, we find that two squares $(x_1, y_1)$ and $(x_2, y_2)$ with the same color satisfy that both $x_1 + y_1$ and $x_2 + y_2$ are either odd or even.
7272

73-
Therefore, we can get the corresponding coordinates $(x, y)$ from `coordinates`. If $x + y$ is odd, then the square is white, return `true`, otherwisereturn `false`.
73+
Therefore, we can get the corresponding coordinates $(x, y)$ from $\textit{coordinates}$. If $x + y$ is odd, the square is white, and we return $\textit{true}$; otherwise, we return $\textit{false}$.
7474

7575
The time complexity is $O(1),ドル and the space complexity is $O(1)$.
7676

@@ -140,9 +140,7 @@ impl Solution {
140140
* @return {boolean}
141141
*/
142142
var squareIsWhite = function (coordinates) {
143-
const x = coordinates.charAt(0).charCodeAt();
144-
const y = coordinates.charAt(1).charCodeAt();
145-
return (x + y) % 2 == 1;
143+
return (coordinates[0].charCodeAt() + coordinates[1].charCodeAt()) % 2 == 1;
146144
};
147145
```
148146

‎solution/1800-1899/1812.Determine Color of a Chessboard Square/Solution.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
* @return {boolean}
44
*/
55
var squareIsWhite = function (coordinates) {
6-
const x = coordinates.charAt(0).charCodeAt();
7-
const y = coordinates.charAt(1).charCodeAt();
8-
return (x + y) % 2 == 1;
6+
return (coordinates[0].charCodeAt() + coordinates[1].charCodeAt()) % 2 == 1;
97
};

‎solution/1800-1899/1891.Cutting Ribbons/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tags:
3333

3434
</ul>
3535

36-
<p>Your task is to determine the <strong>maximum</strong> length of ribbon, <code>x</code>, that allows you to cut <em>exactly</em> <code>k</code> ribbons, each of length <code>x</code>. You can discard any leftover ribbon from the cuts. If it is <strong>impossible</strong> to cut <code>k</code> ribbons of the same length, return 0.</p>
36+
<p>Your task is to determine the <strong>maximum</strong> length of ribbon, <code>x</code>, that allows you to cut <em>at least</em> <code>k</code> ribbons, each of length <code>x</code>. You can discard any leftover ribbon from the cuts. If it is <strong>impossible</strong> to cut <code>k</code> ribbons of the same length, return 0.</p>
3737

3838
<p>&nbsp;</p>
3939
<p><strong class="example">Example 1:</strong></p>

‎solution/2500-2599/2557.Maximum Number of Integers to Choose From a Range II/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tags:
4646
<strong>Input:</strong> banned = [4,3,5,6], n = 7, maxSum = 18
4747
<strong>Output:</strong> 3
4848
<strong>Explanation:</strong> You can choose the integers 1, 2, and 7.
49-
All these integers are in the range [1, 7], all do not appear in banned, and their sum is 18, which does not exceed maxSum.
49+
All these integers are in the range [1, 7], all do not appear in banned, and their sum is 10, which does not exceed maxSum.
5050
</pre>
5151

5252
<p>&nbsp;</p>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /