From 3105cb71d9b5110c8d89e15fa344688ddee3470a Mon Sep 17 00:00:00 2001 From: acbin <44314231+acbin@users.noreply.github.com> Date: Sun, 7 Jan 2024 08:17:17 +0000 Subject: [PATCH] feat: add weekly contest 379 --- .../README.md | 86 ++++++++++++ .../README_EN.md | 76 +++++++++++ .../README.md | 100 ++++++++++++++ .../README_EN.md | 90 +++++++++++++ .../images/ex1.png | Bin 0 -> 2059661 bytes .../images/ex2.png | Bin 0 -> 2051228 bytes .../README.md | 94 ++++++++++++++ .../README_EN.md | 85 ++++++++++++ .../README.md | 122 ++++++++++++++++++ .../README_EN.md | 113 ++++++++++++++++ solution/CONTEST_README.md | 7 + solution/CONTEST_README_EN.md | 7 + solution/README.md | 4 + solution/README_EN.md | 4 + solution/summary.md | 4 + solution/summary_en.md | 4 + 16 files changed, 796 insertions(+) create mode 100644 solution/10000-10099/10035.Maximum Area of Longest Diagonal Rectangle/README.md create mode 100644 solution/10000-10099/10035.Maximum Area of Longest Diagonal Rectangle/README_EN.md create mode 100644 solution/10000-10099/10036.Minimum Moves to Capture The Queen/README.md create mode 100644 solution/10000-10099/10036.Minimum Moves to Capture The Queen/README_EN.md create mode 100644 solution/10000-10099/10036.Minimum Moves to Capture The Queen/images/ex1.png create mode 100644 solution/10000-10099/10036.Minimum Moves to Capture The Queen/images/ex2.png create mode 100644 solution/10000-10099/10037.Maximum Size of a Set After Removals/README.md create mode 100644 solution/10000-10099/10037.Maximum Size of a Set After Removals/README_EN.md create mode 100644 solution/10000-10099/10038.Maximize the Number of Partitions After Operations/README.md create mode 100644 solution/10000-10099/10038.Maximize the Number of Partitions After Operations/README_EN.md diff --git a/solution/10000-10099/10035.Maximum Area of Longest Diagonal Rectangle/README.md b/solution/10000-10099/10035.Maximum Area of Longest Diagonal Rectangle/README.md new file mode 100644 index 0000000000000..572f31398e032 --- /dev/null +++ b/solution/10000-10099/10035.Maximum Area of Longest Diagonal Rectangle/README.md @@ -0,0 +1,86 @@ +# [10035. 对角线最长的矩形的面积](https://leetcode.cn/problems/maximum-area-of-longest-diagonal-rectangle) + +[English Version](/solution/10000-10099/10035.Maximum%20Area%20of%20Longest%20Diagonal%20Rectangle/README_EN.md) + +## 题目描述 + + + +
给你一个下标从 0 开始的二维整数数组 dimensions
。
对于所有下标 i
(0 <= i < dimensions.length
),dimensions[i][0]
表示矩形 i
的长度,而 dimensions[i][1]
表示矩形 i
的宽度。
返回对角线最 长 的矩形的 面积 。如果存在多个对角线长度相同的矩形,返回面积最 大 的矩形的面积。
+ ++ +
示例 1:
+ ++输入:dimensions = [[9,3],[8,6]] +输出:48 +解释: +下标 = 0,长度 = 9,宽度 = 3。对角线长度 = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487。 +下标 = 1,长度 = 8,宽度 = 6。对角线长度 = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10。 +因此,下标为 1 的矩形对角线更长,所以返回面积 = 8 * 6 = 48。 ++ +
示例 2:
+ ++输入:dimensions = [[3,4],[4,3]] +输出:12 +解释:两个矩形的对角线长度相同,为 5,所以最大面积 = 12。 ++ +
+ +
提示:
+ +1 <= dimensions.length <= 100
dimensions[i].length == 2
1 <= dimensions[i][0], dimensions[i][1] <= 100
You are given a 2D 0-indexed integer array dimensions
.
For all indices i
, 0 <= i < dimensions.length
, dimensions[i][0]
represents the length and dimensions[i][1]
represents the width of the rectangle i
.
Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diagonal, return the area of the rectangle having the maximum area.
+ ++
Example 1:
+ ++Input: dimensions = [[9,3],[8,6]] +Output: 48 +Explanation: +For index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487. +For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10. +So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48. ++ +
Example 2:
+ ++Input: dimensions = [[3,4],[4,3]] +Output: 12 +Explanation: Length of diagonal is the same for both which is 5, so maximum area = 12. ++ +
+
Constraints:
+ +1 <= dimensions.length <= 100
dimensions[i].length == 2
1 <= dimensions[i][0], dimensions[i][1] <= 100
现有一个下标从 0 开始的 8 x 8
棋盘,上面有 3
枚棋子。
给你 6
个整数 a
、b
、c
、d
、e
和 f
,其中:
(a, b)
表示白色车的位置。(c, d)
表示白色象的位置。(e, f)
表示黑皇后的位置。假定你只能移动白色棋子,返回捕获黑皇后所需的最少移动次数。
+ +请注意:
+ ++ +
示例 1:
++输入:a = 1, b = 1, c = 8, d = 8, e = 2, f = 3 +输出:2 +解释:将白色车先移动到 (1, 3) ,然后移动到 (2, 3) 来捕获黑皇后,共需移动 2 次。 +由于起始时没有任何棋子正在攻击黑皇后,要想捕获黑皇后,移动次数不可能少于 2 次。 ++ +
示例 2:
++输入:a = 5, b = 3, c = 3, d = 4, e = 5, f = 2 +输出:1 +解释:可以通过以下任一方式移动 1 次捕获黑皇后: +- 将白色车移动到 (5, 2) 。 +- 将白色象移动到 (5, 2) 。 ++ +
+ +
提示:
+ +1 <= a, b, c, d, e, f <= 8
There is a 1-indexed 8 x 8
chessboard containing 3
pieces.
You are given 6
integers a
, b
, c
, d
, e
, and f
where:
(a, b)
denotes the position of the white rook.(c, d)
denotes the position of the white bishop.(e, f)
denotes the position of the black queen.Given that you can only move the white pieces, return the minimum number of moves required to capture the black queen.
+ +Note that:
+ ++
Example 1:
++Input: a = 1, b = 1, c = 8, d = 8, e = 2, f = 3 +Output: 2 +Explanation: We can capture the black queen in two moves by moving the white rook to (1, 3) then to (2, 3). +It is impossible to capture the black queen in less than two moves since it is not being attacked by any of the pieces at the beginning. ++ +
Example 2:
++Input: a = 5, b = 3, c = 3, d = 4, e = 5, f = 2 +Output: 1 +Explanation: We can capture the black queen in a single move by doing one of the following: +- Move the white rook to (5, 2). +- Move the white bishop to (5, 2). ++ +
+
Constraints:
+ +1 <= a, b, c, d, e, f <= 8
S*;$Xb%mQ{-PktomfwYg+8d^UTR}V;R*iU?r~zIYlm&
zfo4V{x{MG>MVl+=rvkt1-N^8VUyH*a|Em%-05zd`4xRLT8R8Eq(H7SAD;;D=fj?8>
zYsbLo9`@T%_#Cj8SQxwEH&H$NK&G58aOXznY!8>X-eSdvsjHn=LF5(N2Is3^J7bPA
zzFDKicKC8!bRqcAwA*%Kc7p1A->CTwja015nzY%&aWJXr;}7<#P&*?+A}HYF@LsR=
zymt_~EJV-`$UhAQum&E$hLSQ>2|_uF{9hsD|EMAVUr8h|_B&da$pOy?vZ4y!2(W*q
zW689*h#~l$ca4lH*I_$v(LAHH$^YRNs*lL=LN<@mO(U1Ly4dvH?-qznhJ7<&cr`W&
z)k96a`B;vKsK4vdwRJ4}CXik?xo1HT
zYu9Dm1pcjba^NfJ0QrHdiI;Fm<}x7KgfW%@I*osUaXtv0LkWPzSglJoA1~0``cYz@
ze*=o;y0haJ;lPD|MTabf1oT5vD^I|EpB0X%=#gqEz5s3`R)8>a$u$3408D?C`hfb2
zy59j}x-?60Qi+>0$HG%#gqwK5oR3mLGL|06A@T()7Z&+!T%%aCRDWAuL0fq)qr3ie
zJ3^R%V1@9`#5#|Xd+*quad#EmsXXKA=O3Cc#{L&!P@>T@*eKRy-`F5laYH*j*gg%U
z2F2Q<%DxABmA_c{xr1`rfTzS?mU&?|zo5!+`F3fv-{rLEmj+L&q1^?}p3D*0B8bXc
zqM!2QLeG5)Y#yw&1Ka3%di70<_7rZEYrHzo<3rDI{lIw7juu|_PLH;z$?xolueup0
z^=V4!2QDeyL=XL(!Y360i_S`hmg`*AWLM?$I%`gWhEOgY