1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-04-18 08:39:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
zhangbk1 2024-09-19 09:27:23 +08:00
parent 1bb2fbd76e
commit fc8e794743
110 changed files with 28402 additions and 16028 deletions
README.md
leetcode-cn
origin-data.json
originData
problem (Chinese)
problem (English)
到达数组末尾的最大得分(English) [reach-end-of-array-with-max-score].html吃掉所有兵需要的最多移动次数(English) [maximum-number-of-moves-to-kill-all-pawns].html哈希分割字符串(English) [hash-divided-string].html对 Bob 造成的最少伤害(English) [minimum-amount-of-damage-dealt-to-bob].html将日期转换为二进制表示(English) [convert-date-to-binary].html形成目标字符串需要的最少字符串数 I(English) [minimum-number-of-valid-strings-to-form-target-i].html形成目标字符串需要的最少字符串数 II(English) [minimum-number-of-valid-strings-to-form-target-ii].html找到稳定山的下标(English) [find-indices-of-stable-mountains].html数字小镇中的捣蛋鬼(English) [the-two-sneaky-numbers-of-digitville].html最长上升路径的长度(English) [length-of-the-longest-increasing-path].html最高乘法得分(English) [maximum-multiplication-score].html查询子数组最大异或值(English) [maximum-xor-score-subarray-queries].html检查棋盘方格颜色是否相同(English) [check-if-two-chessboard-squares-have-the-same-color].html求出数字答案(English) [find-the-key-of-the-numbers].html求出数组中最大序列值(English) [find-the-maximum-sequence-value-of-array].html穿越网格图的安全路径(English) [find-a-safe-walk-through-a-grid].html第 K 近障碍物查询(English) [k-th-nearest-obstacle-queries].html统计好整数的数目(English) [find-the-count-of-good-integers].html范围内整数的最大得分(English) [maximize-score-of-numbers-in-ranges].html选择矩阵中单元格的最大得分(English) [select-cells-in-grid-with-maximum-score].html
leetcode

@ -1,6 +1,6 @@
# 力扣题库(完整版)
> 最后更新日期: **2024.08.27**
> 最后更新日期: **2024.09.19**
>
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件

File diff suppressed because it is too large Load Diff

@ -0,0 +1,64 @@
{
"data": {
"question": {
"questionId": "3609",
"questionFrontendId": "3293",
"categoryTitle": "Database",
"boundTopicId": 2920566,
"title": "Calculate Product Final Price",
"titleSlug": "calculate-product-final-price",
"content": null,
"translatedTitle": "计算产品最终价格",
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"21\", \"totalSubmission\": \"24\", \"totalAcceptedRaw\": 21, \"totalSubmissionRaw\": 24, \"acRate\": \"87.5%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Products\":[\"product_id\",\"category\",\"price\"],\"Discounts\":[\"category\",\"discount\"]},\"rows\":{\"Products\":[[1,\"Electronics\",1000],[2,\"Clothing\",50],[3,\"Electronics\",1200],[4,\"Home\",500]],\"Discounts\":[[\"Electronics\",10],[\"Clothing\",20]]}}",
"metaData": "{\"mysql\":[\"Create table if not exists Products (product_id int, category varchar(50), price int)\",\"Create table if not exists Discounts(category varchar(50), discount int)\"],\"mssql\":[\"Create table Products (product_id int, category varchar(50), price int)\",\"Create table Discounts(category varchar(50), discount int)\"],\"oraclesql\":[\"Create table Products (product_id Number, category varchar2(50), price Number)\",\"Create table Discounts(category varchar2(50), discount Number)\"],\"database\":true,\"name\":\"calculate_final_prices\",\"postgresql\":[\"CREATE TABLE IF NOT EXISTS Products (\\n product_id INT,\\n category VARCHAR(50),\\n price INT\\n);\\n\",\"CREATE TABLE IF NOT EXISTS Discounts (\\n category VARCHAR(50),\\n discount INT\\n);\\n\"],\"pythondata\":[\"Products = pd.DataFrame(columns=['product_id', 'category', 'price'], dtype=int)\\n\",\"Discounts = pd.DataFrame({'category': pd.Series(dtype='str'), 'discount': pd.Series(dtype='int')})\\n\"],\"database_schema\":{\"Products\":{\"product_id\":\"INT\",\"category\":\"VARCHAR(50)\",\"price\":\"INT\"},\"Discounts\":{\"category\":\"VARCHAR(50)\",\"discount\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists Products (product_id int, category varchar(50), price int)",
"Create table if not exists Discounts(category varchar(50), discount int)",
"Truncate table Products",
"insert into Products (product_id, category, price) values ('1', 'Electronics', '1000')",
"insert into Products (product_id, category, price) values ('2', 'Clothing', '50')",
"insert into Products (product_id, category, price) values ('3', 'Electronics', '1200')",
"insert into Products (product_id, category, price) values ('4', 'Home', '500')",
"Truncate table Discounts",
"insert into Discounts (category, discount) values ('Electronics', '10')",
"insert into Discounts (category, discount) values ('Clothing', '20')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Products\":[\"product_id\",\"category\",\"price\"],\"Discounts\":[\"category\",\"discount\"]},\"rows\":{\"Products\":[[1,\"Electronics\",1000],[2,\"Clothing\",50],[3,\"Electronics\",1200],[4,\"Home\",500]],\"Discounts\":[[\"Electronics\",10],[\"Clothing\",20]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,76 @@
{
"data": {
"question": {
"questionId": "3589",
"questionFrontendId": "3278",
"categoryTitle": "Database",
"boundTopicId": 2900887,
"title": "Find Candidates for Data Scientist Position II",
"titleSlug": "find-candidates-for-data-scientist-position-ii",
"content": null,
"translatedTitle": "寻找数据科学家职位的候选人 II",
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"70\", \"totalSubmission\": \"132\", \"totalAcceptedRaw\": 70, \"totalSubmissionRaw\": 132, \"acRate\": \"53.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Candidates\":[\"candidate_id\",\"skill\",\"proficiency\"],\"Projects\":[\"project_id\",\"skill\",\"importance\"]},\"rows\":{\"Candidates\":[[101,\"Python\",5],[101,\"Tableau\",3],[101,\"PostgreSQL\",4],[101,\"TensorFlow\",2],[102,\"Python\",4],[102,\"Tableau\",5],[102,\"PostgreSQL\",4],[102,\"R\",4],[103,\"Python\",3],[103,\"Tableau\",5],[103,\"PostgreSQL\",5],[103,\"Spark\",4]],\"Projects\":[[501,\"Python\",4],[501,\"Tableau\",3],[501,\"PostgreSQL\",5],[502,\"Python\",3],[502,\"Tableau\",4],[502,\"R\",2]]}}",
"metaData": "{\"mysql\":[\"Create table if not exists Candidates(candidate_id int, skill varchar(50), proficiency int)\",\"Create table if not exists Projects( project_id int, skill varchar(50), importance int)\"],\"mssql\":[\"Create table Candidates(candidate_id int, skill varchar(50), proficiency int)\",\"Create table Projects( project_id int, skill varchar(50), importance int)\"],\"oraclesql\":[\"Create table Candidates(candidate_id number, skill varchar2(50), proficiency number)\",\"Create table Projects(project_id number, skill varchar2(50), importance number)\"],\"database\":true,\"name\":\"find_best_candidates\",\"postgresql\":[\"CREATE TABLE IF NOT EXISTS Candidates (\\n candidate_id INT,\\n skill VARCHAR(50),\\n proficiency INT\\n);\\n\",\"CREATE TABLE IF NOT EXISTS Projects (\\n project_id INT,\\n skill VARCHAR(50),\\n importance INT\\n);\\n\"],\"pythondata\":[\"Candidates = pd.DataFrame({\\n 'candidate_id': pd.Series(dtype='int'),\\n 'skill': pd.Series(dtype='str'),\\n 'proficiency': pd.Series(dtype='int')\\n})\",\"Projects = pd.DataFrame({\\n 'project_id': pd.Series(dtype='int'),\\n 'skill': pd.Series(dtype='str'),\\n 'importance': pd.Series(dtype='int')\\n})\"],\"database_schema\":{\"Candidates\":{\"candidate_id\":\"INT\",\"skill\":\"VARCHAR(50)\",\"proficiency\":\"INT\"},\"Projects\":{\"project_id\":\"INT\",\"skill\":\"VARCHAR(50)\",\"importance\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists Candidates(candidate_id int, skill varchar(50), proficiency int)",
"Create table if not exists Projects( project_id int, skill varchar(50), importance int)",
"Truncate table Candidates",
"insert into Candidates (candidate_id, skill, proficiency) values ('101', 'Python', '5')",
"insert into Candidates (candidate_id, skill, proficiency) values ('101', 'Tableau', '3')",
"insert into Candidates (candidate_id, skill, proficiency) values ('101', 'PostgreSQL', '4')",
"insert into Candidates (candidate_id, skill, proficiency) values ('101', 'TensorFlow', '2')",
"insert into Candidates (candidate_id, skill, proficiency) values ('102', 'Python', '4')",
"insert into Candidates (candidate_id, skill, proficiency) values ('102', 'Tableau', '5')",
"insert into Candidates (candidate_id, skill, proficiency) values ('102', 'PostgreSQL', '4')",
"insert into Candidates (candidate_id, skill, proficiency) values ('102', 'R', '4')",
"insert into Candidates (candidate_id, skill, proficiency) values ('103', 'Python', '3')",
"insert into Candidates (candidate_id, skill, proficiency) values ('103', 'Tableau', '5')",
"insert into Candidates (candidate_id, skill, proficiency) values ('103', 'PostgreSQL', '5')",
"insert into Candidates (candidate_id, skill, proficiency) values ('103', 'Spark', '4')",
"Truncate table Projects",
"insert into Projects (project_id, skill, importance) values ('501', 'Python', '4')",
"insert into Projects (project_id, skill, importance) values ('501', 'Tableau', '3')",
"insert into Projects (project_id, skill, importance) values ('501', 'PostgreSQL', '5')",
"insert into Projects (project_id, skill, importance) values ('502', 'Python', '3')",
"insert into Projects (project_id, skill, importance) values ('502', 'Tableau', '4')",
"insert into Projects (project_id, skill, importance) values ('502', 'R', '2')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Candidates\":[\"candidate_id\",\"skill\",\"proficiency\"],\"Projects\":[\"project_id\",\"skill\",\"importance\"]},\"rows\":{\"Candidates\":[[101,\"Python\",5],[101,\"Tableau\",3],[101,\"PostgreSQL\",4],[101,\"TensorFlow\",2],[102,\"Python\",4],[102,\"Tableau\",5],[102,\"PostgreSQL\",4],[102,\"R\",4],[103,\"Python\",3],[103,\"Tableau\",5],[103,\"PostgreSQL\",5],[103,\"Spark\",4]],\"Projects\":[[501,\"Python\",4],[501,\"Tableau\",3],[501,\"PostgreSQL\",5],[502,\"Python\",3],[502,\"Tableau\",4],[502,\"R\",2]]}}",
"__typename": "QuestionNode"
}
}
}

@ -0,0 +1,62 @@
{
"data": {
"question": {
"questionId": "3585",
"questionFrontendId": "3268",
"categoryTitle": "Database",
"boundTopicId": 2895162,
"title": "Find Overlapping Shifts II",
"titleSlug": "find-overlapping-shifts-ii",
"content": null,
"translatedTitle": "查找重叠的班次 II",
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Hard",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"90\", \"totalSubmission\": \"127\", \"totalAcceptedRaw\": 90, \"totalSubmissionRaw\": 127, \"acRate\": \"70.9%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"EmployeeShifts\":[\"employee_id\",\"start_time\",\"end_time\"]},\"rows\":{\"EmployeeShifts\":[[1,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"],[1,\"2023-10-01 15:00:00\",\"2023-10-01 23:00:00\"],[1,\"2023-10-01 16:00:00\",\"2023-10-02 00:00:00\"],[2,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"],[2,\"2023-10-01 11:00:00\",\"2023-10-01 19:00:00\"],[3,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"]]}}",
"metaData": "{\"mysql\":[\"Create table if not exists EmployeeShifts(employee_id int, start_time datetime, end_time datetime)\"],\"mssql\":[\"Create table EmployeeShifts(employee_id int, start_time datetime, end_time datetime)\"],\"oraclesql\":[\"Create table EmployeeShifts(employee_id number, start_time date, end_time date)\",\"ALTER SESSION SET nls_date_format='YYYY-MM-DD HH24:MI:SS'\"],\"database\":true,\"name\":\"calculate_shift_overlaps\",\"postgresql\":[\"CREATE TABLE IF NOT EXISTS EmployeeShifts (\\n employee_id INT,\\n start_time TIMESTAMP,\\n end_time TIMESTAMP\\n);\\n\"],\"pythondata\":[\"EmployeeShifts = pd.DataFrame({\\n 'employee_id': pd.Series(dtype='int'),\\n 'start_time': pd.Series(dtype='datetime64[ns]'),\\n 'end_time': pd.Series(dtype='datetime64[ns]')\\n})\"],\"database_schema\":{\"EmployeeShifts\":{\"employee_id\":\"INT\",\"start_time\":\"DATETIME\",\"end_time\":\"DATETIME\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists EmployeeShifts(employee_id int, start_time datetime, end_time datetime)",
"Truncate table EmployeeShifts",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('1', '2023-10-01 09:00:00', '2023-10-01 17:00:00')",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('1', '2023-10-01 15:00:00', '2023-10-01 23:00:00')",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('1', '2023-10-01 16:00:00', '2023-10-02 00:00:00')",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('2', '2023-10-01 09:00:00', '2023-10-01 17:00:00')",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('2', '2023-10-01 11:00:00', '2023-10-01 19:00:00')",
"insert into EmployeeShifts (employee_id, start_time, end_time) values ('3', '2023-10-01 09:00:00', '2023-10-01 17:00:00')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\": {\"EmployeeShifts\":[\"employee_id\",\"start_time\",\"end_time\"]},\"rows\":{\"EmployeeShifts\":[[1,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"],[1,\"2023-10-01 15:00:00\",\"2023-10-01 23:00:00\"],[1,\"2023-10-01 16:00:00\",\"2023-10-02 00:00:00\"],[2,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"],[2,\"2023-10-01 11:00:00\",\"2023-10-01 19:00:00\"],[3,\"2023-10-01 09:00:00\",\"2023-10-01 17:00:00\"]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,42 @@
<p>给你一个长度为 <code>n</code>&nbsp;的整数数组&nbsp;<code>nums</code>&nbsp;</p>
<p>你的目标是从下标 <code>0</code>&nbsp;出发,到达下标 <code>n - 1</code>&nbsp;处。每次你只能移动到&nbsp;<strong>更大</strong>&nbsp;的下标处。</p>
<p>从下标 <code>i</code>&nbsp;跳到下标 <code>j</code>&nbsp;的得分为&nbsp;<code>(j - i) * nums[i]</code>&nbsp;</p>
<p>请你返回你到达最后一个下标处能得到的 <strong>最大总得分</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [1,3,1,5]</span></p>
<p><b>输出:</b>7</p>
<p><b>解释:</b></p>
<p>一开始跳到下标 1 处,然后跳到最后一个下标处。总得分为&nbsp;<code>1 * 1 + 2 * 3 = 7</code>&nbsp;</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [4,3,1,3,2]</span></p>
<p><b>输出:</b>16</p>
<p><strong>解释:</strong></p>
<p>直接跳到最后一个下标处。总得分为&nbsp;<code>4 * 4 = 16</code>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,78 @@
<p>给你一个&nbsp;<code>50 x 50</code>&nbsp;的国际象棋棋盘,棋盘上有 <strong>一个</strong>&nbsp;马和一些兵。给你两个整数&nbsp;<code>kx</code>&nbsp;<code>ky</code>&nbsp;,其中&nbsp;<code>(kx, ky)</code>&nbsp;表示马所在的位置,同时还有一个二维数组&nbsp;<code>positions</code>&nbsp;,其中&nbsp;<code>positions[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>&nbsp;表示第 <code>i</code>&nbsp;个兵在棋盘上的位置。</p>
<p>Alice 和 Bob 玩一个回合制游戏Alice 先手。玩家的一次操作中,可以执行以下操作:</p>
<ul>
<li>玩家选择一个仍然在棋盘上的兵,然后移动马,通过 <strong>最少</strong>&nbsp;<strong>步数</strong> 吃掉这个兵。<strong>注意</strong>&nbsp;,玩家可以选择&nbsp;<strong>任意</strong>&nbsp;一个兵,<strong>不一定</strong>&nbsp;要选择从马的位置出发&nbsp;<strong>最少</strong>&nbsp;移动步数的兵。</li>
<li><span>在马吃兵的过程中,马 <strong>可能</strong>&nbsp;会经过一些其他兵的位置,但这些兵 <strong>不会</strong>&nbsp;被吃掉。<strong>只有</strong>&nbsp;选中的兵在这个回合中被吃掉。</span></li>
</ul>
<p>Alice 的目标是 <strong>最大化</strong>&nbsp;两名玩家的 <strong></strong>&nbsp;移动次数,直到棋盘上不再存在兵,而 Bob 的目标是 <strong>最小化</strong>&nbsp;总移动次数。</p>
<p>假设两名玩家都采用 <strong>最优</strong>&nbsp;策略,请你返回可以达到的 <strong>最大</strong>&nbsp;总移动次数。</p>
<p>在一次&nbsp;<strong>移动</strong>&nbsp;中,如下图所示,马有 8 个可以移动到的位置,每个移动位置都是沿着坐标轴的一个方向前进 2 格,然后沿着垂直的方向前进 1 格。</p>
<p><img src="https://assets.leetcode.com/uploads/2024/08/01/chess_knight.jpg" style="width: 275px; height: 273px;" /></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>kx = 1, ky = 1, positions = [[0,0]]</span></p>
<p><span class="example-io"><b>输出:</b>4</span></p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/08/16/gif3.gif" style="width: 275px; height: 275px;" /></p>
<p>马需要移动 4 步吃掉&nbsp;<code>(0, 0)</code>&nbsp;处的兵。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>kx = 0, ky = 2, positions = [[1,1],[2,2],[3,3]]</span></p>
<p><span class="example-io"><b>输出:</b>8</span></p>
<p><strong>解释:</strong></p>
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2024/08/16/gif4.gif" style="width: 320px; height: 320px;" /></strong></p>
<ul>
<li>Alice 选择&nbsp;<code>(2, 2)</code>&nbsp;处的兵,移动马吃掉它需要 2 步:<code>(0, 2) -&gt; (1, 4) -&gt; (2, 2)</code>&nbsp;</li>
<li>Bob 选择&nbsp;<code>(3, 3)</code>&nbsp;处的兵,移动马吃掉它需要 2 步:<code>(2, 2) -&gt; (4, 1) -&gt; (3, 3)</code>&nbsp;</li>
<li>Alice 选择&nbsp;<code>(1, 1)</code>&nbsp;处的兵,移动马吃掉它需要 4 步:<code>(3, 3) -&gt; (4, 1) -&gt; (2, 2) -&gt; (0, 3) -&gt; (1, 1)</code>&nbsp;</li>
</ul>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>kx = 0, ky = 0, positions = [[1,2],[2,4]]</span></p>
<p><span class="example-io"><b>输出:</b>3</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>Alice 选择&nbsp;<code>(2, 4)</code>&nbsp;处的兵,移动马吃掉它需要 2 步:<code>(0, 0) -&gt; (1, 2) -&gt; (2, 4)</code>&nbsp;。注意,<code>(1, 2)</code>&nbsp;处的兵不会被吃掉。</li>
<li>Bob 选择&nbsp;<code>(1, 2)</code>&nbsp;处的兵,移动马吃掉它需要 1 步:<code>(2, 4) -&gt; (1, 2)</code>&nbsp;</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= kx, ky &lt;= 49</code></li>
<li><code>1 &lt;= positions.length &lt;= 15</code></li>
<li><code>positions[i].length == 2</code></li>
<li><code>0 &lt;= positions[i][0], positions[i][1] &lt;= 49</code></li>
<li><code>positions[i]</code>&nbsp;两两互不相同。</li>
<li>输入保证对于所有&nbsp;<code>0 &lt;= i &lt; positions.length</code>&nbsp;,都有&nbsp;<code>positions[i] != [kx, ky]</code>&nbsp;</li>
</ul>

@ -0,0 +1,54 @@
<p>给你一个长度为 <code>n</code>&nbsp;的字符串 <code>s</code>&nbsp;和一个整数&nbsp;<code>k</code>&nbsp;<code>n</code>&nbsp;<code>k</code>&nbsp;<strong>倍数</strong>&nbsp;。你的任务是将字符串 <code>s</code>&nbsp;哈希为一个长度为 <code>n / k</code>&nbsp;的新字符串&nbsp;<code>result</code>&nbsp;</p>
<p>首先,将&nbsp;<code>s</code>&nbsp;分割成&nbsp;<code>n / k</code>&nbsp;&nbsp;<strong><span data-keyword="substring-nonempty">子字符串</span></strong>&nbsp;,每个子字符串的长度都为&nbsp;<code>k</code>&nbsp;。然后,将&nbsp;<code>result</code>&nbsp;初始化为一个 <strong></strong>&nbsp;字符串。</p>
<p>我们依次从前往后处理每一个 <strong>子字符串</strong>&nbsp;</p>
<ul>
<li>一个字符的 <strong>哈希值</strong>&nbsp;是它在 <strong>字母表</strong>&nbsp;中的下标(也就是&nbsp;<code>'a' →<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 0</code>&nbsp;<code>'b' →<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 1</code>&nbsp;... <code>'z' →<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 25</code>)。</li>
<li>将子字符串中字幕的 <strong>哈希值</strong>&nbsp;求和。</li>
<li>将和对 26 取余,将结果记为&nbsp;<code>hashedChar</code>&nbsp;</li>
<li>找到小写字母表中 <code>hashedChar</code>&nbsp;对应的字符。</li>
<li>将该字符添加到&nbsp;<code>result</code>&nbsp;的末尾。</li>
</ul>
<p>返回&nbsp;<code>result</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "abcd", k = 2</span></p>
<p><span class="example-io"><b>输出:</b>"bf"</span></p>
<p><b>解释:</b></p>
<p>第一个字符串为&nbsp;<code>"ab"</code>&nbsp;<code>0 + 1 = 1</code>&nbsp;<code>1 % 26 = 1</code>&nbsp;<code>result[0] = 'b'</code>&nbsp;</p>
<p>第二个字符串为: <code>"cd"</code>&nbsp;<code>2 + 3 = 5</code>&nbsp;<code>5 % 26 = 5</code>&nbsp;<code>result[1] = 'f'</code>&nbsp;</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "mxz", k = 3</span></p>
<p><span class="example-io"><b>输出:</b>"i"</span></p>
<p><b>解释:</b></p>
<p>唯一的子字符串为&nbsp;<code>"mxz"</code>&nbsp;<code>12 + 23 + 25 = 60</code>&nbsp;<code>60 % 26 = 8</code>&nbsp;<code>result[0] = 'i'</code>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= k &lt;= 100</code></li>
<li><code>k &lt;= s.length &lt;= 1000</code></li>
<li><code>s.length</code>&nbsp;能被 <code>k</code>&nbsp;整除。</li>
<li><code>s</code> 只含有小写英文字母。</li>
</ul>

@ -0,0 +1,61 @@
<p>给你一个整数&nbsp;<code>power</code>&nbsp;和两个整数数组&nbsp;<code>damage</code>&nbsp;<code>health</code>&nbsp;,两个数组的长度都为&nbsp;<code>n</code>&nbsp;</p>
<p>Bob 有&nbsp;<code>n</code>&nbsp;个敌人,如果第&nbsp;<code>i</code>&nbsp;个敌人还活着(也就是健康值&nbsp;<code>health[i] &gt; 0</code>&nbsp;的时候),每秒钟会对 Bob 造成&nbsp;<code>damage[i]</code>&nbsp;<strong></strong>&nbsp;伤害。</p>
<p>每一秒中,在敌人对 Bob 造成伤害 <strong>之后</strong>&nbsp;Bob 会选择 <strong>一个</strong>&nbsp;还活着的敌人进行攻击,该敌人的健康值减少 <code>power</code>&nbsp;</p>
<p>请你返回 Bob 将 <strong>所有</strong>&nbsp;<code>n</code>&nbsp;个敌人都消灭之前,<strong>最少</strong>&nbsp;会收到多少伤害。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>power = 4, damage = [1,2,3,4], health = [4,5,6,8]</span></p>
<p><span class="example-io"><b>输出:</b>39</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>最开始 2 秒内都攻击敌人 3 ,然后敌人 3 会被消灭,这段时间内对 Bob 的总伤害是&nbsp;<code>10 + 10 = 20</code>&nbsp;点。</li>
<li>接下来 2 秒内都攻击敌人 2 ,然后敌人 2 会被消灭,这段时间内对 Bob 的总伤害是&nbsp;<code>6 + 6 = 12</code>&nbsp;点。</li>
<li>接下来 1 秒内都攻击敌人 0 ,然后敌人 0 会被消灭,这段时间内对 Bob 的总伤害是&nbsp;<code>3</code>&nbsp;点。</li>
<li>接下来 2 秒内都攻击敌人 1 ,然后敌人 1 会被消灭,这段时间内对 Bob 的总伤害是&nbsp;<code>2 + 2 = 4</code>&nbsp;点。</li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>power = 1, damage = [1,1,1,1], health = [1,2,3,4]</span></p>
<p><span class="example-io"><b>输出:</b>20</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>最开始 1 秒内都攻击敌人 0 ,然后敌人 0 会被消灭,这段时间对 Bob 的总伤害是&nbsp;<code>4</code>&nbsp;点。</li>
<li>接下来 2 秒内都攻击敌人 1 ,然后敌人 1 会被消灭,这段时间对 Bob 的总伤害是&nbsp;<code>3 + 3 = 6</code>&nbsp;点。</li>
<li>接下来 3 秒内都攻击敌人 2 ,然后敌人 2 会被消灭,这段时间对 Bob 的总伤害是&nbsp;<code>2 + 2 + 2 = 6</code>&nbsp;点。</li>
<li>接下来 4 秒内都攻击敌人 3 ,然后敌人 3 会被消灭,这段时间对 Bob 的总伤害是&nbsp;<code>1 + 1 + 1 + 1 = 4</code>&nbsp;点。</li>
</ul>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>power = 8, damage = [40], health = [59]</span></p>
<p><span class="example-io"><b>输出:</b>320</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= power &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= n == damage.length == health.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= damage[i], health[i] &lt;= 10<sup>4</sup></code></li>
</ul>

@ -0,0 +1,41 @@
<p>给你一个字符串 <code>date</code>,它的格式为 <code>yyyy-mm-dd</code>,表示一个公历日期。</p>
<p><code>date</code> 可以重写为二进制表示,只需要将年、月、日分别转换为对应的二进制表示(不带前导零)并遵循 <code>year-month-day</code> 的格式。</p>
<p>返回 <code>date</code><strong>二进制</strong> 表示。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">date = "2080-02-29"</span></p>
<p><strong>输出:</strong> <span class="example-io">"100000100000-10-11101"</span></p>
<p><strong>解释:</strong></p>
<p><span class="example-io">100000100000, 10 和 11101 分别是 2080, 02 和 29 的二进制表示。</span></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">date = "1900-01-01"</span></p>
<p><strong>输出:</strong> <span class="example-io">"11101101100-1-1"</span></p>
<p><strong>解释:</strong></p>
<p><span class="example-io">11101101100, 1 和 1 分别是 1900, 1 和 1 的二进制表示。</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>date.length == 10</code></li>
<li><code>date[4] == date[7] == '-'</code>,其余的 <code>date[i]</code> 都是数字。</li>
<li>输入保证 <code>date</code> 代表一个有效的公历日期,日期范围从 1900 年 1 月 1 日到 2100 年 12 月 31 日(包括这两天)。</li>
</ul>

@ -0,0 +1,63 @@
<p>给你一个字符串数组 <code>words</code> 和一个字符串 <code>target</code></p>
<p>如果字符串 <code>x</code><code>words</code><strong> 任意 </strong>字符串的 <span data-keyword="string-prefix">前缀</span>,则认为 <code>x</code> 是一个 <strong>有效</strong> 字符串。</p>
<p>现计划通过 <strong>连接 </strong>有效字符串形成 <code>target</code> ,请你计算并返回需要连接的 <strong>最少 </strong>字符串数量。如果无法通过这种方式形成 <code>target</code>,则返回 <code>-1</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abc","aaaaa","bcdef"], target = "aabcdabc"</span></p>
<p><strong>输出:</strong> <span class="example-io">3</span></p>
<p><strong>解释:</strong></p>
<p>target 字符串可以通过连接以下有效字符串形成:</p>
<ul>
<li><code>words[1]</code> 的长度为 2 的前缀,即 <code>"aa"</code></li>
<li><code>words[2]</code> 的长度为 3 的前缀,即 <code>"bcd"</code></li>
<li><code>words[0]</code> 的长度为 3 的前缀,即 <code>"abc"</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abababab","ab"], target = "ababaababa"</span></p>
<p><strong>输出:</strong> <span class="example-io">2</span></p>
<p><strong>解释:</strong></p>
<p>target 字符串可以通过连接以下有效字符串形成:</p>
<ul>
<li><code>words[0]</code> 的长度为 5 的前缀,即 <code>"ababa"</code></li>
<li><code>words[0]</code> 的长度为 5 的前缀,即 <code>"ababa"</code></li>
</ul>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abcdef"], target = "xyz"</span></p>
<p><strong>输出:</strong> <span class="example-io">-1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 5 * 10<sup>3</sup></code></li>
<li>输入确保 <code>sum(words[i].length) &lt;= 10<sup>5</sup></code></li>
<li><code>words[i]</code> 只包含小写英文字母。</li>
<li><code>1 &lt;= target.length &lt;= 5 * 10<sup>3</sup></code></li>
<li><code>target</code> 只包含小写英文字母。</li>
</ul>

@ -0,0 +1,63 @@
<p>给你一个字符串数组 <code>words</code> 和一个字符串 <code>target</code></p>
<p>如果字符串 <code>x</code><code>words</code><strong> 任意 </strong>字符串的 <span data-keyword="string-prefix">前缀</span>,则认为 <code>x</code> 是一个 <strong>有效</strong> 字符串。</p>
<p>现计划通过 <strong>连接 </strong>有效字符串形成 <code>target</code> ,请你计算并返回需要连接的 <strong>最少 </strong>字符串数量。如果无法通过这种方式形成 <code>target</code>,则返回 <code>-1</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abc","aaaaa","bcdef"], target = "aabcdabc"</span></p>
<p><strong>输出:</strong> <span class="example-io">3</span></p>
<p><strong>解释:</strong></p>
<p>target 字符串可以通过连接以下有效字符串形成:</p>
<ul>
<li><code>words[1]</code> 的长度为 2 的前缀,即 <code>"aa"</code></li>
<li><code>words[2]</code> 的长度为 3 的前缀,即 <code>"bcd"</code></li>
<li><code>words[0]</code> 的长度为 3 的前缀,即 <code>"abc"</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abababab","ab"], target = "ababaababa"</span></p>
<p><strong>输出:</strong> <span class="example-io">2</span></p>
<p><strong>解释:</strong></p>
<p>target 字符串可以通过连接以下有效字符串形成:</p>
<ul>
<li><code>words[0]</code> 的长度为 5 的前缀,即 <code>"ababa"</code></li>
<li><code>words[0]</code> 的长度为 5 的前缀,即 <code>"ababa"</code></li>
</ul>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">words = ["abcdef"], target = "xyz"</span></p>
<p><strong>输出:</strong> <span class="example-io">-1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 5 * 10<sup>4</sup></code></li>
<li>输入确保 <code>sum(words[i].length) &lt;= 10<sup>5</sup></code>.</li>
<li><code>words[i]</code> &nbsp;只包含小写英文字母。</li>
<li><code>1 &lt;= target.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>target</code> &nbsp;只包含小写英文字母。</li>
</ul>

@ -0,0 +1,48 @@
<p>&nbsp;<code>n</code>&nbsp;座山排成一列,每座山都有一个高度。给你一个整数数组&nbsp;<code>height</code>&nbsp;,其中&nbsp;<code>height[i]</code>&nbsp;表示第 <code>i</code>&nbsp;座山的高度,再给你一个整数&nbsp;<code>threshold</code>&nbsp;</p>
<p>对于下标不为 <code>0</code>&nbsp;的一座山,如果它左侧相邻的山的高度 <strong>严格</strong><strong>大于</strong>&nbsp;<code>threshold</code>&nbsp;,那么我们称它是 <strong>稳定</strong>&nbsp;的。我们定义下标为 <code>0</code>&nbsp;的山 <strong>不是</strong>&nbsp;稳定的。</p>
<p>请你返回一个数组,包含所有 <strong>稳定</strong>&nbsp;山的下标,你可以以 <strong>任意</strong>&nbsp;顺序返回下标数组。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>height = [1,2,3,4,5], threshold = 2</span></p>
<p><span class="example-io"><b>输出:</b>[3,4]</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>下标为 3 的山是稳定的,因为&nbsp;<code>height[2] == 3</code>&nbsp;大于&nbsp;<code>threshold == 2</code>&nbsp;</li>
<li>下标为 4 的山是稳定的,因为&nbsp;<code>height[3] == 4</code> 大于 <code>threshold == 2</code>.</li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>height = [10,1,10,1,10], threshold = 3</span></p>
<p><span class="example-io"><b>输出:</b>[1,3]</span></p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>height = [10,1,10,1,10], threshold = 10</span></p>
<p><span class="example-io"><b>输出:</b>[]</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= n == height.length &lt;= 100</code></li>
<li><code>1 &lt;= height[i] &lt;= 100</code></li>
<li><code>1 &lt;= threshold &lt;= 100</code></li>
</ul>

@ -0,0 +1,54 @@
<p>数字小镇 Digitville 中,存在一个数字列表 <code>nums</code>,其中包含从 <code>0</code><code>n - 1</code> 的整数。每个数字本应 <strong>只出现一次</strong>,然而,有 <strong>两个 </strong>顽皮的数字额外多出现了一次,使得列表变得比正常情况下更长。</p>
<p>为了恢复 Digitville 的和平,作为小镇中的名侦探,请你找出这两个顽皮的数字。</p>
<p>返回一个长度为 2 的数组,包含这两个数字(顺序任意)。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [0,1,1,0]</span></p>
<p><strong>输出:</strong> <span class="example-io">[0,1]</span></p>
<p><strong>解释:</strong></p>
<p>数字 0 和 1 分别在数组中出现了两次。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [0,3,2,1,3,2]</span></p>
<p><strong>输出:</strong> <span class="example-io">[2,3]</span></p>
<p><strong>解释: </strong></p>
<p>数字 2 和 3 分别在数组中出现了两次。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [7,1,5,4,3,4,6,0,9,5,8,2]</span></p>
<p><strong>输出:</strong> <span class="example-io">[4,5]</span></p>
<p><strong>解释: </strong></p>
<p>数字 4 和 5 分别在数组中出现了两次。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= n &lt;= 100</code></li>
<li><code>nums.length == n + 2</code></li>
<li><code>0 &lt;= nums[i] &lt; n</code></li>
<li>输入保证 <code>nums</code><strong> 恰好 </strong>包含两个重复的元素。</li>
</ul>

@ -0,0 +1,50 @@
<p>给你一个长度为 <code>n</code>&nbsp;的二维整数数组&nbsp;<code>coordinates</code>&nbsp;和一个整数&nbsp;<code>k</code>&nbsp;,其中&nbsp;<code>0 &lt;= k &lt; n</code>&nbsp;</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>&nbsp;表示二维平面里一个点&nbsp;<code>(x<sub>i</sub>, y<sub>i</sub>)</code>&nbsp;</p>
<p>如果一个点序列&nbsp;<code>(x<sub>1</sub>, y<sub>1</sub>)</code>, <code>(x<sub>2</sub>, y<sub>2</sub>)</code>, <code>(x<sub>3</sub>, y<sub>3</sub>)</code>, ..., <code>(x<sub>m</sub>, y<sub>m</sub>)</code>&nbsp;满足以下条件,那么我们称它是一个长度为 <code>m</code>&nbsp;<strong>上升序列</strong>&nbsp;</p>
<ul>
<li>对于所有满足&nbsp;<code>1 &lt;= i &lt; m</code>&nbsp;<code>i</code>&nbsp;都有&nbsp;<code>x<sub>i</sub> &lt; x<sub>i + 1</sub></code>&nbsp;&nbsp;<code>y<sub>i</sub> &lt; y<sub>i + 1</sub></code>&nbsp;</li>
<li>对于所有&nbsp;<code>1 &lt;= i &lt;= m</code>&nbsp;&nbsp;<code>i</code>&nbsp;对应的点&nbsp;<code>(x<sub>i</sub>, y<sub>i</sub>)</code>&nbsp;都在给定的坐标数组里。</li>
</ul>
<p>请你返回包含坐标 <code>coordinates[k]</code>&nbsp;<strong>最长上升路径</strong>&nbsp;的长度。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>coordinates = [[3,1],[2,2],[4,1],[0,0],[5,3]], k = 1</span></p>
<p><span class="example-io"><b>输出:</b>3</span></p>
<p><strong>解释:</strong></p>
<p><code>(0, 0)</code>&nbsp;<code>(2, 2)</code>&nbsp;<code>(5, 3)</code><!-- notionvc: 082cee9e-4ce5-4ede-a09d-57001a72141d -->&nbsp;是包含坐标 <code>(2, 2)</code>&nbsp;的最长上升路径。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>coordinates = [[2,1],[7,0],[5,6]], k = 2</span></p>
<p><span class="example-io"><b>输出:</b>2</span></p>
<p><b>解释:</b></p>
<p><code>(2, 1)</code>&nbsp;<code>(5, 6)</code>&nbsp;是包含坐标 <code>(5, 6)</code>&nbsp;的最长上升路径。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n == coordinates.length &lt;= 10<sup>5</sup></code></li>
<li><code>coordinates[i].length == 2</code></li>
<li><code>0 &lt;= coordinates[i][0], coordinates[i][1] &lt;= 10<sup>9</sup></code></li>
<li><code>coordinates</code>&nbsp;中的元素 <strong>互不相同</strong>&nbsp;<!-- notionvc: 6e412fc2-f9dd-4ba2-b796-5e802a2b305a --><!-- notionvc: c2cf5618-fe99-4909-9b4c-e6b068be22a6 --></li>
<li><code>0 &lt;= k &lt;= n - 1</code></li>
</ul>

@ -0,0 +1,39 @@
<p>给你一个大小为 4 的整数数组 <code>a</code> 和一个大小 <strong>至少</strong>为 4 的整数数组 <code>b</code></p>
<p>你需要从数组 <code>b</code> 中选择四个下标 <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, 和 <code>i<sub>3</sub></code>,并满足 <code>i<sub>0</sub> &lt; i<sub>1</sub> &lt; i<sub>2</sub> &lt; i<sub>3</sub></code>。你的得分将是 <code>a[0] * b[i<sub>0</sub>] + a[1] * b[i<sub>1</sub>] + a[2] * b[i<sub>2</sub>] + a[3] * b[i<sub>3</sub>]</code> 的值。</p>
<p>返回你能够获得的 <strong>最大 </strong>得分。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">a = [3,2,5,6], b = [2,-6,4,-5,-3,2,-7]</span></p>
<p><strong>输出:</strong> <span class="example-io">26</span></p>
<p><strong>解释:</strong><br />
选择下标 0, 1, 2 和 5。得分为 <code>3 * 2 + 2 * (-6) + 5 * 4 + 6 * 2 = 26</code></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">a = [-1,4,5,-2], b = [-5,-1,-3,-2,-4]</span></p>
<p><strong>输出:</strong> <span class="example-io">-1</span></p>
<p><strong>解释:</strong><br />
选择下标 0, 1, 3 和 4。得分为 <code>(-1) * (-5) + 4 * (-1) + 5 * (-2) + (-2) * (-4) = -1</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>a.length == 4</code></li>
<li><code>4 &lt;= b.length &lt;= 10<sup>5</sup></code></li>
<li><code>-10<sup>5</sup> &lt;= a[i], b[i] &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,96 @@
<p>给你一个由 <code>n</code> 个整数组成的数组 <code>nums</code>,以及一个大小为 <code>q</code> 的二维整数数组 <code>queries</code>,其中 <code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code></p>
<p>对于每一个查询,你需要找出 <code>nums[l<sub>i</sub>..r<sub>i</sub>]</code> 中任意 <span data-keyword="subarray">子数组</span><strong>最大异或值</strong></p>
<p><strong>数组的异或值 </strong>需要对数组 <code>a</code> 反复执行以下操作,直到只剩一个元素,剩下的那个元素就是 <strong>异或值</strong></p>
<ul>
<li><span class="text-only" data-eleid="9" style="white-space: pre;">对于除最后一个下标以外的所有下标</span> <code>i</code>,同时将 <code>a[i]</code> 替换为 <code>a[i] XOR a[i + 1]</code></li>
<li>移除数组的最后一个元素。</li>
</ul>
<p>返回一个大小为 <code>q</code> 的数组 <code>answer</code>,其中 <code>answer[i]</code> 表示查询 <code>i</code> 的答案。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [2,8,4,32,16,1], queries = [[0,2],[1,4],[0,5]]</span></p>
<p><strong>输出:</strong> <span class="example-io">[12,60,60]</span></p>
<p><strong>解释:</strong></p>
<p>在第一个查询中,<code>nums[0..2]</code> 的子数组分别是 <code>[2]</code>, <code>[8]</code>, <code>[4]</code>, <code>[2, 8]</code>, <code>[8, 4]</code>, 和 <code>[2, 8, 4]</code>,它们的异或值分别为 2, 8, 4, 10, 12, 和 6。查询的答案是 12所有异或值中的最大值。</p>
<p>在第二个查询中,<code>nums[1..4]</code> 的子数组中最大的异或值是子数组 <code>nums[1..4]</code> 的异或值,为 60。</p>
<p>在第三个查询中,<code>nums[0..5]</code> 的子数组中最大的异或值是子数组 <code>nums[1..4]</code> 的异或值,为 60。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [0,7,3,2,8,5,1], queries = [[0,3],[1,5],[2,4],[2,6],[5,6]]</span></p>
<p><strong>输出:</strong> <span class="example-io">[7,14,11,14,5]</span></p>
<p><strong>解释:</strong></p>
<table height="70" width="472">
<thead>
<tr>
<th>下标</th>
<th>nums[l<sub>i</sub>..r<sub>i</sub>]</th>
<th>最大异或值子数组</th>
<th>子数组最大异或值</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>[0, 7, 3, 2]</td>
<td>[7]</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>[7, 3, 2, 8, 5]</td>
<td>[7, 3, 2, 8]</td>
<td>14</td>
</tr>
<tr>
<td>2</td>
<td>[3, 2, 8]</td>
<td>[3, 2, 8]</td>
<td>11</td>
</tr>
<tr>
<td>3</td>
<td>[3, 2, 8, 5, 1]</td>
<td>[2, 8, 5, 1]</td>
<td>14</td>
</tr>
<tr>
<td>4</td>
<td>[5, 1]</td>
<td>[5]</td>
<td>5</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n == nums.length &lt;= 2000</code></li>
<li><code>0 &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
<li><code>1 &lt;= q == queries.length &lt;= 10<sup>5</sup></code></li>
<li><code>queries[i].length == 2</code></li>
<li><code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code></li>
<li><code>0 &lt;= l<sub>i</sub> &lt;= r<sub>i</sub> &lt;= n - 1</code></li>
</ul>

@ -0,0 +1,45 @@
<p>给你两个字符串 <code>coordinate1</code><code>coordinate2</code>,代表 <code>8 x 8</code> 国际象棋棋盘上的两个方格的坐标。</p>
<p>以下是棋盘的参考图。</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png" style="width: 400px; height: 396px;" /></p>
<p>如果这两个方格颜色相同,返回 <code>true</code>,否则返回 <code>false</code></p>
<p>坐标总是表示有效的棋盘方格。坐标的格式总是先字母(表示列),再数字(表示行)。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "c3"</span></p>
<p><strong>输出:</strong> <span class="example-io">true</span></p>
<p><strong>解释:</strong></p>
<p>两个方格均为黑色。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">coordinate1 = "a1", coordinate2 = "h3"</span></p>
<p><strong>输出:</strong> <span class="example-io">false</span></p>
<p><strong>解释:</strong></p>
<p>方格 <code>"a1"</code> 是黑色,而 <code>"h3"</code> 是白色。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>coordinate1.length == coordinate2.length == 2</code></li>
<li><code>'a' &lt;= coordinate1[0], coordinate2[0] &lt;= 'h'</code></li>
<li><code>'1' &lt;= coordinate1[1], coordinate2[1] &lt;= '8'</code></li>
</ul>

@ -0,0 +1,57 @@
<p>给你三个 <strong></strong>&nbsp;整数&nbsp;<code>num1</code>&nbsp;<code>num2</code>&nbsp;&nbsp;<code>num3</code>&nbsp;</p>
<p>数字 <code>num1</code>&nbsp;<code>num2</code>&nbsp;<code>num3</code>&nbsp;的数字答案 <code>key</code>&nbsp;是一个四位数,定义如下:</p>
<ul>
<li>一开始,如果有数字 <strong>少于</strong>&nbsp;四位数,给它补 <strong>前导 0 </strong></li>
<li>答案 <code>key</code>&nbsp;的第&nbsp;<code>i</code>&nbsp;个数位(<code>1 &lt;= i &lt;= 4</code>)为&nbsp;<code>num1</code>&nbsp;<code>num2</code>&nbsp;&nbsp;<code>num3</code>&nbsp;&nbsp;<code>i</code>&nbsp;个数位中的&nbsp;<strong>最小</strong>&nbsp;值。</li>
</ul>
<p>请你返回三个数字 <strong>没有</strong>&nbsp;前导 0 的数字答案。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>num1 = 1, num2 = 10, num3 = 1000</span></p>
<p><span class="example-io"><b>输出:</b>0</span></p>
<p><b>解释:</b></p>
<p>补前导 0 后,<code>num1</code>&nbsp;变为&nbsp;<code>"0001"</code>&nbsp;<code>num2</code> 变为&nbsp;<code>"0010"</code>&nbsp;<code>num3</code>&nbsp;保持不变,为&nbsp;<code>"1000"</code>&nbsp;</p>
<ul>
<li>数字答案 <code>key</code>&nbsp;的第&nbsp;<code>1</code>&nbsp;个数位为&nbsp;<code>min(0, 0, 1)</code>&nbsp;</li>
<li>数字答案 <code>key</code>&nbsp;的第&nbsp;<code>2</code>&nbsp;个数位为&nbsp;<code>min(0, 0, 0)</code>&nbsp;</li>
<li>数字答案 <code>key</code>&nbsp;的第 <code>3</code> 个数位为&nbsp;<code>min(0, 1, 0)</code>&nbsp;</li>
<li>数字答案 <code>key</code>&nbsp;的第 <code>4</code> 个数位为&nbsp;<code>min(1, 0, 0)</code>&nbsp;</li>
</ul>
<p>所以数字答案为&nbsp;<code>"0000"</code>&nbsp;,也就是 0 。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">num1 = 987, num2 = 879, num3 = 798</span></p>
<p><span class="example-io"><b>输出:</b>777</span></p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>num1 = 1, num2 = 2, num3 = 3</span></p>
<p><span class="example-io"><b>输出:</b>1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= num1, num2, num3 &lt;= 9999</code></li>
</ul>

@ -0,0 +1,45 @@
<p>给你一个整数数组&nbsp;<code>nums</code>&nbsp;和一个 <strong></strong>&nbsp;整数&nbsp;<code>k</code>&nbsp;</p>
<p>定义长度为 <code>2 * x</code>&nbsp;的序列 <code>seq</code>&nbsp;<strong></strong>&nbsp;为:</p>
<ul>
<li><code>(seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1])</code>.</li>
</ul>
<p>请你求出 <code>nums</code>&nbsp;中所有长度为 <code>2 * k</code>&nbsp;<span data-keyword="subsequence-array">子序列</span><strong>最大值</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [2,6,7], k = 1</span></p>
<p><span class="example-io"><b>输出:</b>5</span></p>
<p><strong>解释:</strong></p>
<p>子序列&nbsp;<code>[2, 7]</code>&nbsp;的值最大,为&nbsp;<code>2 XOR 7 = 5</code>&nbsp;</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>nums = [4,2,5,6,7], k = 2</span></p>
<p><span class="example-io"><b>输出:</b>2</span></p>
<p><strong>解释:</strong></p>
<p>子序列&nbsp;<code>[4, 5, 6, 7]</code>&nbsp;的值最大,为&nbsp;<code>(4 OR 5) XOR (6 OR 7) = 2</code>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 400</code></li>
<li><code>1 &lt;= nums[i] &lt; 2<sup>7</sup></code></li>
<li><code>1 &lt;= k &lt;= nums.length / 2</code></li>
</ul>

@ -0,0 +1,66 @@
<p>给你一个&nbsp;<code>m x n</code>&nbsp;的二进制矩形&nbsp;<code>grid</code>&nbsp;和一个整数&nbsp;<code>health</code>&nbsp;表示你的健康值。</p>
<p>你开始于矩形的左上角&nbsp;<code>(0, 0)</code>&nbsp;,你的目标是矩形的右下角&nbsp;<code>(m - 1, n - 1)</code>&nbsp;</p>
<p>你可以在矩形中往上下左右相邻格子移动,但前提是你的健康值始终是 <b>正数</b>&nbsp;</p>
<p>对于格子&nbsp;<code>(i, j)</code>&nbsp;,如果&nbsp;<code>grid[i][j] = 1</code>&nbsp;,那么这个格子视为 <strong>不安全</strong>&nbsp;的,会使你的健康值减少 1 。</p>
<p>如果你可以到达最终的格子,请你返回&nbsp;<code>true</code>&nbsp;,否则返回 <code>false</code>&nbsp;</p>
<p><b>注意</b>&nbsp;,当你在最终格子的时候,你的健康值也必须为<strong>&nbsp;正数</strong>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]], health = 1</span></p>
<p><span class="example-io"><b>输出:</b>true</span></p>
<p><b>解释:</b></p>
<p>沿着下图中灰色格子走,可以安全到达最终的格子。</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_1drawio.png" style="width: 301px; height: 121px;" /></div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>grid = [[0,1,1,0,0,0],[1,0,1,0,0,0],[0,1,1,1,0,1],[0,0,1,0,1,0]], health = 3</span></p>
<p><span class="example-io"><b>输出:</b>false</span></p>
<p><b>解释:</b></p>
<p>健康值最少为 4 才能安全到达最后的格子。</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_2drawio.png" style="width: 361px; height: 161px;" /></div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>grid = [[1,1,1],[1,0,1],[1,1,1]], health = 5</span></p>
<p><span class="example-io"><b>输出:</b>true</span></p>
<p><b>解释:</b></p>
<p>沿着下图中灰色格子走,可以安全到达最终的格子。</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_3drawio.png" style="width: 181px; height: 121px;" /></p>
<p>任何不经过格子&nbsp;<code>(1, 1)</code>&nbsp;的路径都是不安全的,因为你的健康值到达最终格子时,都会小于等于 0 。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 50</code></li>
<li><code>2 <= m * n</code></li>
<li><code>1 &lt;= health &lt;= m + n</code></li>
<li><code>grid[i][j]</code>&nbsp;要么是 0 ,要么是 1 。</li>
</ul>

@ -0,0 +1,63 @@
<p>有一个无限大的二维平面。</p>
<p>给你一个正整数&nbsp;<code>k</code>&nbsp;,同时给你一个二维数组&nbsp;<code>queries</code>&nbsp;,包含一系列查询:</p>
<ul>
<li><code>queries[i] = [x, y]</code>&nbsp;:在平面上坐标&nbsp;<code>(x, y)</code>&nbsp;处建一个障碍物,数据保证之前的查询 <strong>不会</strong> 在这个坐标处建立任何障碍物。</li>
</ul>
<p>每次查询后,你需要找到离原点第 <code>k</code>&nbsp;<strong></strong>&nbsp;障碍物到原点的 <strong>距离</strong>&nbsp;</p>
<p>请你返回一个整数数组&nbsp;<code>results</code>&nbsp;,其中&nbsp;<code>results[i]</code>&nbsp;表示建立第 <code>i</code>&nbsp;个障碍物以后,离原地第 <code>k</code>&nbsp;近障碍物距离原点的距离。如果少于 <code>k</code>&nbsp;个障碍物,<code>results[i] == -1</code>&nbsp;</p>
<p><strong>注意</strong>,一开始&nbsp;<strong>没有</strong>&nbsp;任何障碍物。</p>
<p>坐标在&nbsp;<code>(x, y)</code>&nbsp;处的点距离原点的距离定义为&nbsp;<code>|x| + |y|</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>queries = [[1,2],[3,4],[2,3],[-3,0]], k = 2</span></p>
<p><span class="example-io"><b>输出:</b>[-1,7,5,3]</span></p>
<p><strong>解释:</strong></p>
<p>最初,不存在障碍物。</p>
<ul>
<li><code>queries[0]</code>&nbsp;之后,少于 2 个障碍物。</li>
<li><code>queries[1]</code>&nbsp;之后,&nbsp;两个障碍物距离原点的距离分别为 3 和 7 。</li>
<li><code>queries[2]</code>&nbsp;之后,障碍物距离原点的距离分别为 3 5 和 7 。</li>
<li><code>queries[3]</code>&nbsp;之后,障碍物距离原点的距离分别为 335 和 7 。</li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>queries = [[5,5],[4,4],[3,3]], k = 1</span></p>
<p><span class="example-io"><b>输出:</b>[10,8,6]</span></p>
<p><b>解释:</b></p>
<ul>
<li><code>queries[0]</code>&nbsp;之后,只有一个障碍物,距离原点距离为 10 。</li>
<li><code>queries[1]</code>&nbsp;之后,障碍物距离原点距离分别为 8 和 10 。</li>
<li><code>queries[2]</code>&nbsp;之后,障碍物距离原点的距离分别为 6 8 和10 。</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= queries.length &lt;= 2 * 10<sup>5</sup></code></li>
<li>所有&nbsp;<code>queries[i]</code>&nbsp;互不相同。</li>
<li><code>-10<sup>9</sup> &lt;= queries[i][0], queries[i][1] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,62 @@
<p>给你两个 <strong></strong>&nbsp;整数&nbsp;<code>n</code>&nbsp;<code>k</code>&nbsp;</p>
<p>如果一个整数&nbsp;<code>x</code>&nbsp;满足以下条件,那么它被称为 <strong>k</strong><strong>&nbsp;回文</strong>&nbsp;整数&nbsp;</p>
<ul>
<li><code>x</code>&nbsp;是一个&nbsp;<span data-keyword="palindrome-integer">回文整数 。</span></li>
<li><code>x</code>&nbsp;能被 <code>k</code>&nbsp;整除。</li>
</ul>
<p>如果一个整数的数位重新排列后能得到一个 <strong>k 回文整数</strong>&nbsp;,那么我们称这个整数为&nbsp;<strong></strong>整数。比方说,<code>k = 2</code>&nbsp;,那么&nbsp;2020 可以重新排列得到 2002 2002 是一个 k 回文串,所以 2020 是一个好整数。而 1010 无法重新排列数位得到一个 k 回文整数。</p>
<p>请你返回 <code>n</code>&nbsp;个数位的整数中,有多少个 <strong></strong>&nbsp;整数。</p>
<p><b>注意</b>&nbsp;,任何整数在重新排列数位之前或者之后 <strong>都不能</strong> 有前导 0 。比方说 1010 不能重排列得到&nbsp;101 。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>n = 3, k = 5</span></p>
<p><span class="example-io"><b>输出:</b>27</span></p>
<p><b>解释:</b></p>
<p>部分好整数如下:</p>
<ul>
<li>551 ,因为它可以重排列得到 515 。</li>
<li>525 ,因为它已经是一个 k 回文整数。</li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>n = 1, k = 4</span></p>
<p><span class="example-io"><b>输出:</b>2</span></p>
<p><strong>解释:</strong></p>
<p>两个好整数分别是 4 和 8 。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><span class="example-io"><b>输入:</b>n = 5, k = 6</span></p>
<p><span class="example-io"><b>输出:</b>2468</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10</code></li>
<li><code>1 &lt;= k &lt;= 9</code></li>
</ul>

@ -0,0 +1,41 @@
<p>给你一个整数数组 <code>start</code> 和一个整数 <code>d</code>,代表 <code>n</code> 个区间 <code>[start[i], start[i] + d]</code></p>
<p>你需要选择 <code>n</code> 个整数,其中第 <code>i</code> 个整数必须属于第 <code>i</code> 个区间。所选整数的 <strong>得分</strong> 定义为所选整数两两之间的 <strong>最小 </strong>绝对差。</p>
<p>返回所选整数的 <strong>最大可能得分 </strong></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">start = [6,0,3], d = 2</span></p>
<p><strong>输出:</strong> <span class="example-io">4</span></p>
<p><strong>解释:</strong></p>
<p>可以选择整数 8, 0 和 4 获得最大可能得分,得分为 <code>min(|8 - 0|, |8 - 4|, |0 - 4|)</code>,等于 4。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">start = [2,6,13,13], d = 5</span></p>
<p><strong>输出:</strong> <span class="example-io">5</span></p>
<p><strong>解释:</strong></p>
<p>可以选择整数 2, 7, 13 和 18 获得最大可能得分,得分为 <code>min(|2 - 7|, |2 - 13|, |2 - 18|, |7 - 13|, |7 - 18|, |13 - 18|)</code>,等于 5。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= start.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= start[i] &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= d &lt;= 10<sup>9</sup></code></li>
</ul>

@ -0,0 +1,51 @@
<p>给你一个由正整数构成的二维矩阵 <code>grid</code></p>
<p>你需要从矩阵中选择<strong> 一个或多个 </strong>单元格,选中的单元格应满足以下条件:</p>
<ul>
<li>所选单元格中的任意两个单元格都不会处于矩阵的 <strong>同一行</strong></li>
<li>所选单元格的值 <strong>互不相同</strong></li>
</ul>
<p>你的得分为所选单元格值的<strong>总和</strong></p>
<p>返回你能获得的<strong> 最大 </strong>得分。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">grid = [[1,2,3],[4,3,2],[1,1,1]]</span></p>
<p><strong>输出:</strong> <span class="example-io">8</span></p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/29/grid1drawio.png" /></p>
<p>选择上图中用彩色标记的单元格,对应的值分别为 1、3 和 4 。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">grid = [[8,7,6],[8,3,2]]</span></p>
<p><strong>输出:</strong> <span class="example-io">15</span></p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/29/grid8_8drawio.png" style="width: 170px; height: 114px;" /></p>
<p>选择上图中用彩色标记的单元格,对应的值分别为 7 和 8 。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= grid.length, grid[i].length &lt;= 10</code></li>
<li><code>1 &lt;= grid[i][j] &lt;= 100</code></li>
</ul>

@ -0,0 +1,40 @@
<p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</code> is calculated as <code>(j - i) * nums[i]</code>.</p>
<p>Return the <strong>maximum</strong> possible <b>total score</b> by the time you reach the last index.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,3,1,5]</span></p>
<p><strong>Output:</strong> 7</p>
<p><strong>Explanation:</strong></p>
<p>First, jump to index 1 and then jump to the last index. The final score is <code>1 * 1 + 2 * 3 = 7</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,3,1,3,2]</span></p>
<p><strong>Output:</strong> 16</p>
<p><strong>Explanation:</strong></p>
<p>Jump directly to the last index. The final score is <code>4 * 4 = 16</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,76 @@
<p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> denotes the position of the pawns on the chessboard.</p>
<p>Alice and Bob play a <em>turn-based</em> game, where Alice goes first. In each player&#39;s turn:</p>
<ul>
<li>The player <em>selects </em>a pawn that still exists on the board and captures it with the knight in the <strong>fewest</strong> possible <strong>moves</strong>. <strong>Note</strong> that the player can select <strong>any</strong> pawn, it <strong>might not</strong> be one that can be captured in the <strong>least</strong> number of moves.</li>
<li><span>In the process of capturing the <em>selected</em> pawn, the knight <strong>may</strong> pass other pawns <strong>without</strong> capturing them</span>. <strong>Only</strong> the <em>selected</em> pawn can be captured in <em>this</em> turn.</li>
</ul>
<p>Alice is trying to <strong>maximize</strong> the <strong>sum</strong> of the number of moves made by <em>both</em> players until there are no more pawns on the board, whereas Bob tries to <strong>minimize</strong> them.</p>
<p>Return the <strong>maximum</strong> <em>total</em> number of moves made during the game that Alice can achieve, assuming both players play <strong>optimally</strong>.</p>
<p>Note that in one <strong>move, </strong>a chess knight has eight possible positions it can move to, as illustrated below. Each move is two cells in a cardinal direction, then one cell in an orthogonal direction.</p>
<p><img src="https://assets.leetcode.com/uploads/2024/08/01/chess_knight.jpg" style="width: 275px; height: 273px;" /></p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">kx = 1, ky = 1, positions = [[0,0]]</span></p>
<p><strong>Output:</strong> <span class="example-io">4</span></p>
<p><strong>Explanation:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/08/16/gif3.gif" style="width: 275px; height: 275px;" /></p>
<p>The knight takes 4 moves to reach the pawn at <code>(0, 0)</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">kx = 0, ky = 2, positions = [[1,1],[2,2],[3,3]]</span></p>
<p><strong>Output:</strong> <span class="example-io">8</span></p>
<p><strong>Explanation:</strong></p>
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2024/08/16/gif4.gif" style="width: 320px; height: 320px;" /></strong></p>
<ul>
<li>Alice picks the pawn at <code>(2, 2)</code> and captures it in two moves: <code>(0, 2) -&gt; (1, 4) -&gt; (2, 2)</code>.</li>
<li>Bob picks the pawn at <code>(3, 3)</code> and captures it in two moves: <code>(2, 2) -&gt; (4, 1) -&gt; (3, 3)</code>.</li>
<li>Alice picks the pawn at <code>(1, 1)</code> and captures it in four moves: <code>(3, 3) -&gt; (4, 1) -&gt; (2, 2) -&gt; (0, 3) -&gt; (1, 1)</code>.</li>
</ul>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">kx = 0, ky = 0, positions = [[1,2],[2,4]]</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Alice picks the pawn at <code>(2, 4)</code> and captures it in two moves: <code>(0, 0) -&gt; (1, 2) -&gt; (2, 4)</code>. Note that the pawn at <code>(1, 2)</code> is not captured.</li>
<li>Bob picks the pawn at <code>(1, 2)</code> and captures it in one move: <code>(2, 4) -&gt; (1, 2)</code>.</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 &lt;= kx, ky &lt;= 49</code></li>
<li><code>1 &lt;= positions.length &lt;= 15</code></li>
<li><code>positions[i].length == 2</code></li>
<li><code>0 &lt;= positions[i][0], positions[i][1] &lt;= 49</code></li>
<li>All <code>positions[i]</code> are unique.</li>
<li>The input is generated such that <code>positions[i] != [kx, ky]</code> for all <code>0 &lt;= i &lt; positions.length</code>.</li>
</ul>

@ -0,0 +1,52 @@
<p>You are given a string <code>s</code> of length <code>n</code> and an integer <code>k</code>, where <code>n</code> is a <strong>multiple</strong> of <code>k</code>. Your task is to hash the string <code>s</code> into a new string called <code>result</code>, which has a length of <code>n / k</code>.</p>
<p>First, divide <code>s</code> into <code>n / k</code> <strong><span data-keyword="substring-nonempty">substrings</span></strong>, each with a length of <code>k</code>. Then, initialize <code>result</code> as an <strong>empty</strong> string.</p>
<p>For each <strong>substring</strong> in order from the beginning:</p>
<ul>
<li>The <strong>hash value</strong> of a character is the index of that characte<!-- notionvc: 4b67483a-fa95-40b6-870d-2eacd9bc18d8 -->r in the <strong>English alphabet</strong> (e.g., <code>&#39;a&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 0</code>, <code>&#39;b&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 1</code>, ..., <code>&#39;z&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 25</code>).</li>
<li>Calculate the <em>sum</em> of all the <strong>hash values</strong> of the characters in the substring.</li>
<li>Find the remainder of this sum when divided by 26, which is called <code>hashedChar</code>.</li>
<li>Identify the character in the English lowercase alphabet that corresponds to <code>hashedChar</code>.</li>
<li>Append that character to the end of <code>result</code>.</li>
</ul>
<p>Return <code>result</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;abcd&quot;, k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;bf&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p>First substring: <code>&quot;ab&quot;</code>, <code>0 + 1 = 1</code>, <code>1 % 26 = 1</code>, <code>result[0] = &#39;b&#39;</code>.</p>
<p>Second substring: <code>&quot;cd&quot;</code>, <code>2 + 3 = 5</code>, <code>5 % 26 = 5</code>, <code>result[1] = &#39;f&#39;</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;mxz&quot;, k = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;i&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p>The only substring: <code>&quot;mxz&quot;</code>, <code>12 + 23 + 25 = 60</code>, <code>60 % 26 = 8</code>, <code>result[0] = &#39;i&#39;</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= k &lt;= 100</code></li>
<li><code>k &lt;= s.length &lt;= 1000</code></li>
<li><code>s.length</code> is divisible by <code>k</code>.</li>
<li><code>s</code> consists only of lowercase English letters.</li>
</ul>

@ -0,0 +1,59 @@
<p>You are given an integer <code>power</code> and two integer arrays <code>damage</code> and <code>health</code>, both having length <code>n</code>.</p>
<p>Bob has <code>n</code> enemies, where enemy <code>i</code> will deal Bob <code>damage[i]</code> <strong>points</strong> of damage per second while they are <em>alive</em> (i.e. <code>health[i] &gt; 0</code>).</p>
<p>Every second, <strong>after</strong> the enemies deal damage to Bob, he chooses <strong>one</strong> of the enemies that is still <em>alive</em> and deals <code>power</code> points of damage to them.</p>
<p>Determine the <strong>minimum</strong> total amount of damage points that will be dealt to Bob before <strong>all</strong> <code>n</code> enemies are <em>dead</em>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">power = 4, damage = [1,2,3,4], health = [4,5,6,8]</span></p>
<p><strong>Output:</strong> <span class="example-io">39</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Attack enemy 3 in the first two seconds, after which enemy 3 will go down, the number of damage points dealt to Bob is <code>10 + 10 = 20</code> points.</li>
<li>Attack enemy 2 in the next two seconds, after which enemy 2 will go down, the number of damage points dealt to Bob is <code>6 + 6 = 12</code> points.</li>
<li>Attack enemy 0 in the next second, after which enemy 0 will go down, the number of damage points dealt to Bob is <code>3</code> points.</li>
<li>Attack enemy 1 in the next two seconds, after which enemy 1 will go down, the number of damage points dealt to Bob is <code>2 + 2 = 4</code> points.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">power = 1, damage = [1,1,1,1], health = [1,2,3,4]</span></p>
<p><strong>Output:</strong> <span class="example-io">20</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Attack enemy 0 in the first second, after which enemy 0 will go down, the number of damage points dealt to Bob is <code>4</code> points.</li>
<li>Attack enemy 1 in the next two seconds, after which enemy 1 will go down, the number of damage points dealt to Bob is <code>3 + 3 = 6</code> points.</li>
<li>Attack enemy 2 in the next three seconds, after which enemy 2 will go down, the number of damage points dealt to Bob is <code>2 + 2 + 2 = 6</code> points.</li>
<li>Attack enemy 3 in the next four seconds, after which enemy 3 will go down, the number of damage points dealt to Bob is <code>1 + 1 + 1 + 1 = 4</code> points.</li>
</ul>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">power = 8, damage = [40], health = [59]</span></p>
<p><strong>Output:</strong> <span class="example-io">320</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= power &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= n == damage.length == health.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= damage[i], health[i] &lt;= 10<sup>4</sup></code></li>
</ul>

@ -0,0 +1,39 @@
<p>You are given a string <code>date</code> representing a Gregorian calendar date in the <code>yyyy-mm-dd</code> format.</p>
<p><code>date</code> can be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down in <code>year-month-day</code> format.</p>
<p>Return the <strong>binary</strong> representation of <code>date</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">date = &quot;2080-02-29&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;100000100000-10-11101&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p><span class="example-io">100000100000, 10, and 11101 are the binary representations of 2080, 02, and 29 respectively.</span></p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">date = &quot;1900-01-01&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;11101101100-1-1&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p><span class="example-io">11101101100, 1, and 1 are the binary representations of 1900, 1, and 1 respectively.</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>date.length == 10</code></li>
<li><code>date[4] == date[7] == &#39;-&#39;</code>, and all other <code>date[i]</code>&#39;s are digits.</li>
<li>The input is generated such that <code>date</code> represents a valid Gregorian calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>st</sup>, 2100 (both inclusive).</li>
</ul>

@ -0,0 +1,61 @@
<p>You are given an array of strings <code>words</code> and a string <code>target</code>.</p>
<p>A string <code>x</code> is called <strong>valid</strong> if <code>x</code> is a <span data-keyword="string-prefix">prefix</span> of <strong>any</strong> string in <code>words</code>.</p>
<p>Return the <strong>minimum</strong> number of <strong>valid</strong> strings that can be <em>concatenated</em> to form <code>target</code>. If it is <strong>not</strong> possible to form <code>target</code>, return <code>-1</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abc&quot;,&quot;aaaaa&quot;,&quot;bcdef&quot;], target = &quot;aabcdabc&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<p>The target string can be formed by concatenating:</p>
<ul>
<li>Prefix of length 2 of <code>words[1]</code>, i.e. <code>&quot;aa&quot;</code>.</li>
<li>Prefix of length 3 of <code>words[2]</code>, i.e. <code>&quot;bcd&quot;</code>.</li>
<li>Prefix of length 3 of <code>words[0]</code>, i.e. <code>&quot;abc&quot;</code>.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abababab&quot;,&quot;ab&quot;], target = &quot;ababaababa&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The target string can be formed by concatenating:</p>
<ul>
<li>Prefix of length 5 of <code>words[0]</code>, i.e. <code>&quot;ababa&quot;</code>.</li>
<li>Prefix of length 5 of <code>words[0]</code>, i.e. <code>&quot;ababa&quot;</code>.</li>
</ul>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abcdef&quot;], target = &quot;xyz&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">-1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 5 * 10<sup>3</sup></code></li>
<li>The input is generated such that <code>sum(words[i].length) &lt;= 10<sup>5</sup></code>.</li>
<li><code>words[i]</code> consists only of lowercase English letters.</li>
<li><code>1 &lt;= target.length &lt;= 5 * 10<sup>3</sup></code></li>
<li><code>target</code> consists only of lowercase English letters.</li>
</ul>

@ -0,0 +1,61 @@
<p>You are given an array of strings <code>words</code> and a string <code>target</code>.</p>
<p>A string <code>x</code> is called <strong>valid</strong> if <code>x</code> is a <span data-keyword="string-prefix">prefix</span> of <strong>any</strong> string in <code>words</code>.</p>
<p>Return the <strong>minimum</strong> number of <strong>valid</strong> strings that can be <em>concatenated</em> to form <code>target</code>. If it is <strong>not</strong> possible to form <code>target</code>, return <code>-1</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abc&quot;,&quot;aaaaa&quot;,&quot;bcdef&quot;], target = &quot;aabcdabc&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<p>The target string can be formed by concatenating:</p>
<ul>
<li>Prefix of length 2 of <code>words[1]</code>, i.e. <code>&quot;aa&quot;</code>.</li>
<li>Prefix of length 3 of <code>words[2]</code>, i.e. <code>&quot;bcd&quot;</code>.</li>
<li>Prefix of length 3 of <code>words[0]</code>, i.e. <code>&quot;abc&quot;</code>.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abababab&quot;,&quot;ab&quot;], target = &quot;ababaababa&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The target string can be formed by concatenating:</p>
<ul>
<li>Prefix of length 5 of <code>words[0]</code>, i.e. <code>&quot;ababa&quot;</code>.</li>
<li>Prefix of length 5 of <code>words[0]</code>, i.e. <code>&quot;ababa&quot;</code>.</li>
</ul>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">words = [&quot;abcdef&quot;], target = &quot;xyz&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">-1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 5 * 10<sup>4</sup></code></li>
<li>The input is generated such that <code>sum(words[i].length) &lt;= 10<sup>5</sup></code>.</li>
<li><code>words[i]</code> consists only of lowercase English letters.</li>
<li><code>1 &lt;= target.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>target</code> consists only of lowercase English letters.</li>
</ul>

@ -0,0 +1,46 @@
<p>There are <code>n</code> mountains in a row, and each mountain has a height. You are given an integer array <code>height</code> where <code>height[i]</code> represents the height of mountain <code>i</code>, and an integer <code>threshold</code>.</p>
<p>A mountain is called <strong>stable</strong> if the mountain just before it (<strong>if it exists</strong>) has a height <strong>strictly greater</strong> than <code>threshold</code>. <strong>Note</strong> that mountain 0 is <strong>not</strong> stable.</p>
<p>Return an array containing the indices of <em>all</em> <strong>stable</strong> mountains in <strong>any</strong> order.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [1,2,3,4,5], threshold = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">[3,4]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Mountain 3 is stable because <code>height[2] == 3</code> is greater than <code>threshold == 2</code>.</li>
<li>Mountain 4 is stable because <code>height[3] == 4</code> is greater than <code>threshold == 2</code>.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [10,1,10,1,10], threshold = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">[1,3]</span></p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [10,1,10,1,10], threshold = 10</span></p>
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= n == height.length &lt;= 100</code></li>
<li><code>1 &lt;= height[i] &lt;= 100</code></li>
<li><code>1 &lt;= threshold &lt;= 100</code></li>
</ul>

@ -0,0 +1,50 @@
<p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making the list longer than usual.<!-- notionvc: c37cfb04-95eb-4273-85d5-3c52d0525b95 --></p>
<p>As the town detective, your task is to find these two sneaky numbers. Return an array of size <strong>two</strong> containing the two numbers (in <em>any order</em>), so peace can return to Digitville.<!-- notionvc: 345db5be-c788-4828-9836-eefed31c982f --></p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [0,1,1,0]</span></p>
<p><strong>Output:</strong> <span class="example-io">[0,1]</span></p>
<p><strong>Explanation:</strong></p>
<p>The numbers 0 and 1 each appear twice in the array.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [0,3,2,1,3,2]</span></p>
<p><strong>Output:</strong> <span class="example-io">[2,3]</span></p>
<p><strong>Explanation: </strong></p>
<p>The numbers 2 and 3 each appear twice in the array.</p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [7,1,5,4,3,4,6,0,9,5,8,2]</span></p>
<p><strong>Output:</strong> <span class="example-io">[4,5]</span></p>
<p><strong>Explanation: </strong></p>
<p>The numbers 4 and 5 each appear twice in the array.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li data-stringify-border="0" data-stringify-indent="1"><code>2 &lt;= n &lt;= 100</code></li>
<li data-stringify-border="0" data-stringify-indent="1"><code>nums.length == n + 2</code></li>
<li data-stringify-border="0" data-stringify-indent="1"><code data-stringify-type="code">0 &lt;= nums[i] &lt; n</code></li>
<li data-stringify-border="0" data-stringify-indent="1">The input is generated such that <code>nums</code> contains <strong>exactly</strong> two repeated elements.</li>
</ul>

@ -0,0 +1,48 @@
<p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 &lt;= k &lt; n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <strong>increasing path</strong> of length <code>m</code> is defined as a list of points <code>(x<sub>1</sub>, y<sub>1</sub>)</code>, <code>(x<sub>2</sub>, y<sub>2</sub>)</code>, <code>(x<sub>3</sub>, y<sub>3</sub>)</code>, ..., <code>(x<sub>m</sub>, y<sub>m</sub>)</code> such that:</p>
<ul>
<li><code>x<sub>i</sub> &lt; x<sub>i + 1</sub></code> and <code>y<sub>i</sub> &lt; y<sub>i + 1</sub></code> for all <code>i</code> where <code>1 &lt;= i &lt; m</code>.</li>
<li><code>(x<sub>i</sub>, y<sub>i</sub>)</code> is in the given coordinates for all <code>i</code> where <code>1 &lt;= i &lt;= m</code>.</li>
</ul>
<p>Return the <strong>maximum</strong> length of an <strong>increasing path</strong> that contains <code>coordinates[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinates = [[3,1],[2,2],[4,1],[0,0],[5,3]], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<p><code>(0, 0)</code>, <code>(2, 2)</code>, <code>(5, 3)</code><!-- notionvc: 082cee9e-4ce5-4ede-a09d-57001a72141d --> is the longest increasing path that contains <code>(2, 2)</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinates = [[2,1],[7,0],[5,6]], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p><code>(2, 1)</code>, <code>(5, 6)</code> is the longest increasing path that contains <code>(5, 6)</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n == coordinates.length &lt;= 10<sup>5</sup></code></li>
<li><code>coordinates[i].length == 2</code></li>
<li><code>0 &lt;= coordinates[i][0], coordinates[i][1] &lt;= 10<sup>9</sup></code></li>
<li>All elements in <code>coordinates</code> are <strong>distinct</strong>.<!-- notionvc: 6e412fc2-f9dd-4ba2-b796-5e802a2b305a --><!-- notionvc: c2cf5618-fe99-4909-9b4c-e6b068be22a6 --></li>
<li><code>0 &lt;= k &lt;= n - 1</code></li>
</ul>

@ -0,0 +1,37 @@
<p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> such that <code>i<sub>0</sub> &lt; i<sub>1</sub> &lt; i<sub>2</sub> &lt; i<sub>3</sub></code>. Your score will be equal to the value <code>a[0] * b[i<sub>0</sub>] + a[1] * b[i<sub>1</sub>] + a[2] * b[i<sub>2</sub>] + a[3] * b[i<sub>3</sub>]</code>.</p>
<p>Return the <strong>maximum</strong> score you can achieve.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">a = [3,2,5,6], b = [2,-6,4,-5,-3,2,-7]</span></p>
<p><strong>Output:</strong> <span class="example-io">26</span></p>
<p><strong>Explanation:</strong><br />
We can choose the indices 0, 1, 2, and 5. The score will be <code>3 * 2 + 2 * (-6) + 5 * 4 + 6 * 2 = 26</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">a = [-1,4,5,-2], b = [-5,-1,-3,-2,-4]</span></p>
<p><strong>Output:</strong> <span class="example-io">-1</span></p>
<p><strong>Explanation:</strong><br />
We can choose the indices 0, 1, 3, and 4. The score will be <code>(-1) * (-5) + 4 * (-1) + 5 * (-2) + (-2) * (-4) = -1</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>a.length == 4</code></li>
<li><code>4 &lt;= b.length &lt;= 10<sup>5</sup></code></li>
<li><code>-10<sup>5</sup> &lt;= a[i], b[i] &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,94 @@
<p>You are given an array <code>nums</code> of <code>n</code> integers, and a 2D integer array <code>queries</code> of size <code>q</code>, where <code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code>.</p>
<p>For each query, you must find the <strong>maximum XOR score</strong> of any <span data-keyword="subarray">subarray</span> of <code>nums[l<sub>i</sub>..r<sub>i</sub>]</code>.</p>
<p>The <strong>XOR score</strong> of an array <code>a</code> is found by repeatedly applying the following operations on <code>a</code> so that only one element remains, that is the <strong>score</strong>:</p>
<ul>
<li>Simultaneously replace <code>a[i]</code> with <code>a[i] XOR a[i + 1]</code> for all indices <code>i</code> except the last one.</li>
<li>Remove the last element of <code>a</code>.</li>
</ul>
<p>Return an array <code>answer</code> of size <code>q</code> where <code>answer[i]</code> is the answer to query <code>i</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,8,4,32,16,1], queries = [[0,2],[1,4],[0,5]]</span></p>
<p><strong>Output:</strong> <span class="example-io">[12,60,60]</span></p>
<p><strong>Explanation:</strong></p>
<p>In the first query, <code>nums[0..2]</code> has 6 subarrays <code>[2]</code>, <code>[8]</code>, <code>[4]</code>, <code>[2, 8]</code>, <code>[8, 4]</code>, and <code>[2, 8, 4]</code> each with a respective XOR score of 2, 8, 4, 10, 12, and 6. The answer for the query is 12, the largest of all XOR scores.</p>
<p>In the second query, the subarray of <code>nums[1..4]</code> with the largest XOR score is <code>nums[1..4]</code> with a score of 60.</p>
<p>In the third query, the subarray of <code>nums[0..5]</code> with the largest XOR score is <code>nums[1..4]</code> with a score of 60.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [0,7,3,2,8,5,1], queries = [[0,3],[1,5],[2,4],[2,6],[5,6]]</span></p>
<p><strong>Output:</strong> <span class="example-io">[7,14,11,14,5]</span></p>
<p><strong>Explanation:</strong></p>
<table height="70" width="472">
<thead>
<tr>
<th>Index</th>
<th>nums[l<sub>i</sub>..r<sub>i</sub>]</th>
<th>Maximum XOR Score Subarray</th>
<th>Maximum Subarray XOR Score</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>[0, 7, 3, 2]</td>
<td>[7]</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>[7, 3, 2, 8, 5]</td>
<td>[7, 3, 2, 8]</td>
<td>14</td>
</tr>
<tr>
<td>2</td>
<td>[3, 2, 8]</td>
<td>[3, 2, 8]</td>
<td>11</td>
</tr>
<tr>
<td>3</td>
<td>[3, 2, 8, 5, 1]</td>
<td>[2, 8, 5, 1]</td>
<td>14</td>
</tr>
<tr>
<td>4</td>
<td>[5, 1]</td>
<td>[5]</td>
<td>5</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n == nums.length &lt;= 2000</code></li>
<li><code>0 &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
<li><code>1 &lt;= q == queries.length &lt;= 10<sup>5</sup></code></li>
<li><code>queries[i].length == 2 </code></li>
<li><code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code></li>
<li><code>0 &lt;= l<sub>i</sub> &lt;= r<sub>i</sub> &lt;= n - 1</code></li>
</ul>

@ -0,0 +1,43 @@
<p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png" style="width: 400px; height: 396px;" /></p>
<p>Return <code>true</code> if these two squares have the same color and <code>false</code> otherwise.</p>
<p>The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first (indicating its column), and the number second (indicating its row).</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinate1 = &quot;a1&quot;, coordinate2 = &quot;c3&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>Both squares are black.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinate1 = &quot;a1&quot;, coordinate2 = &quot;h3&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">false</span></p>
<p><strong>Explanation:</strong></p>
<p>Square <code>&quot;a1&quot;</code> is black and <code>&quot;h3&quot;</code> is white.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>coordinate1.length == coordinate2.length == 2</code></li>
<li><code>&#39;a&#39; &lt;= coordinate1[0], coordinate2[0] &lt;= &#39;h&#39;</code></li>
<li><code>&#39;1&#39; &lt;= coordinate1[1], coordinate2[1] &lt;= &#39;8&#39;</code></li>
</ul>

@ -0,0 +1,55 @@
<p>You are given three <strong>positive</strong> integers <code>num1</code>, <code>num2</code>, and <code>num3</code>.</p>
<p>The <code>key</code> of <code>num1</code>, <code>num2</code>, and <code>num3</code> is defined as a four-digit number such that:</p>
<ul>
<li>Initially, if any number has <strong>less than</strong> four digits, it is padded with <strong>leading zeros</strong>.</li>
<li>The <code>i<sup>th</sup></code> digit (<code>1 &lt;= i &lt;= 4</code>) of the <code>key</code> is generated by taking the <strong>smallest</strong> digit among the <code>i<sup>th</sup></code> digits of <code>num1</code>, <code>num2</code>, and <code>num3</code>.</li>
</ul>
<p>Return the <code>key</code> of the three numbers <strong>without</strong> leading zeros (<em>if any</em>).</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 1, num2 = 10, num3 = 1000</span></p>
<p><strong>Output:</strong> <span class="example-io">0</span></p>
<p><strong>Explanation:</strong></p>
<p>On padding, <code>num1</code> becomes <code>&quot;0001&quot;</code>, <code>num2</code> becomes <code>&quot;0010&quot;</code>, and <code>num3</code> remains <code>&quot;1000&quot;</code>.</p>
<ul>
<li>The <code>1<sup>st</sup></code> digit of the <code>key</code> is <code>min(0, 0, 1)</code>.</li>
<li>The <code>2<sup>nd</sup></code> digit of the <code>key</code> is <code>min(0, 0, 0)</code>.</li>
<li>The <code>3<sup>rd</sup></code> digit of the <code>key</code> is <code>min(0, 1, 0)</code>.</li>
<li>The <code>4<sup>th</sup></code> digit of the <code>key</code> is <code>min(1, 0, 0)</code>.</li>
</ul>
<p>Hence, the <code>key</code> is <code>&quot;0000&quot;</code>, i.e. 0.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 987, num2 = 879, num3 = 798</span></p>
<p><strong>Output:</strong> <span class="example-io">777</span></p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 1, num2 = 2, num3 = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= num1, num2, num3 &lt;= 9999</code></li>
</ul>

@ -0,0 +1,43 @@
<p>You are given an integer array <code>nums</code> and a <strong>positive</strong> integer <code>k</code>.</p>
<p>The <strong>value</strong> of a sequence <code>seq</code> of size <code>2 * x</code> is defined as:</p>
<ul>
<li><code>(seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1])</code>.</li>
</ul>
<p>Return the <strong>maximum</strong> <strong>value</strong> of any <span data-keyword="subsequence-array">subsequence</span> of <code>nums</code> having size <code>2 * k</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,6,7], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">5</span></p>
<p><strong>Explanation:</strong></p>
<p>The subsequence <code>[2, 7]</code> has the maximum value of <code>2 XOR 7 = 5</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,2,5,6,7], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The subsequence <code>[4, 5, 6, 7]</code> has the maximum value of <code>(4 OR 5) XOR (6 OR 7) = 2</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 400</code></li>
<li><code>1 &lt;= nums[i] &lt; 2<sup>7</sup></code></li>
<li><code>1 &lt;= k &lt;= nums.length / 2</code></li>
</ul>

@ -0,0 +1,62 @@
<p>You are given an <code>m x n</code> binary matrix <code>grid</code> and an integer <code>health</code>.</p>
<p>You start on the upper-left corner <code>(0, 0)</code> and would like to get to the lower-right corner <code>(m - 1, n - 1)</code>.</p>
<p>You can move up, down, left, or right from one cell to another adjacent cell as long as your health <em>remains</em> <strong>positive</strong>.</p>
<p>Cells <code>(i, j)</code> with <code>grid[i][j] = 1</code> are considered <strong>unsafe</strong> and reduce your health by 1.</p>
<p>Return <code>true</code> if you can reach the final cell with a health value of 1 or more, and <code>false</code> otherwise.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]], health = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>The final cell can be reached safely by walking along the gray cells below.</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_1drawio.png" style="width: 301px; height: 121px;" /></div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[0,1,1,0,0,0],[1,0,1,0,0,0],[0,1,1,1,0,1],[0,0,1,0,1,0]], health = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">false</span></p>
<p><strong>Explanation:</strong></p>
<p>A minimum of 4 health points is needed to reach the final cell safely.</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_2drawio.png" style="width: 361px; height: 161px;" /></div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[1,1,1],[1,0,1],[1,1,1]], health = 5</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>The final cell can be reached safely by walking along the gray cells below.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_3drawio.png" style="width: 181px; height: 121px;" /></p>
<p>Any path that does not go through the cell <code>(1, 1)</code> is unsafe since your health will drop to 0 when reaching the final cell.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 50</code></li>
<li><code><font face="monospace">2 &lt;= m * n</font></code></li>
<li><code>1 &lt;= health &lt;= m + n</code></li>
<li><code>grid[i][j]</code> is either 0 or 1.</li>
</ul>

@ -0,0 +1,60 @@
<p>There is an infinite 2D plane.</p>
<p>You are given a positive integer <code>k</code>. You are also given a 2D array <code>queries</code>, which contains the following queries:</p>
<ul>
<li><code>queries[i] = [x, y]</code>: Build an obstacle at coordinate <code>(x, y)</code> in the plane. It is guaranteed that there is <strong>no</strong> obstacle at this coordinate when this query is made.</li>
</ul>
<p>After each query, you need to find the <strong>distance</strong> of the <code>k<sup>th</sup></code> <strong>nearest</strong> obstacle from the origin.</p>
<p>Return an integer array <code>results</code> where <code>results[i]</code> denotes the <code>k<sup>th</sup></code> nearest obstacle after query <code>i</code>, or <code>results[i] == -1</code> if there are less than <code>k</code> obstacles.</p>
<p><strong>Note</strong> that initially there are <strong>no</strong> obstacles anywhere.</p>
<p>The <strong>distance</strong> of an obstacle at coordinate <code>(x, y)</code> from the origin is given by <code>|x| + |y|</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">queries = [[1,2],[3,4],[2,3],[-3,0]], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">[-1,7,5,3]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Initially, there are 0 obstacles.</li>
<li>After <code>queries[0]</code>, there are less than 2 obstacles.</li>
<li>After <code>queries[1]</code>, there are obstacles at distances 3 and 7.</li>
<li>After <code>queries[2]</code>, there are obstacles at distances 3, 5, and 7.</li>
<li>After <code>queries[3]</code>, there are obstacles at distances 3, 3, 5, and 7.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">queries = [[5,5],[4,4],[3,3]], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">[10,8,6]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>After <code>queries[0]</code>, there is an obstacle at distance 10.</li>
<li>After <code>queries[1]</code>, there are obstacles at distances 8 and 10.</li>
<li>After <code>queries[2]</code>, there are obstacles at distances 6, 8, and 10.</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= queries.length &lt;= 2 * 10<sup>5</sup></code></li>
<li>All <code>queries[i]</code> are unique.</li>
<li><code>-10<sup>9</sup> &lt;= queries[i][0], queries[i][1] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,60 @@
<p>You are given two <strong>positive</strong> integers <code>n</code> and <code>k</code>.</p>
<p>An integer <code>x</code> is called <strong>k-palindromic</strong> if:</p>
<ul>
<li><code>x</code> is a <span data-keyword="palindrome-integer">palindrome</span>.</li>
<li><code>x</code> is divisible by <code>k</code>.</li>
</ul>
<p>An integer is called <strong>good</strong> if its digits can be <em>rearranged</em> to form a <strong>k-palindromic</strong> integer. For example, for <code>k = 2</code>, 2020 can be rearranged to form the <em>k-palindromic</em> integer 2002, whereas 1010 cannot be rearranged to form a <em>k-palindromic</em> integer.</p>
<p>Return the count of <strong>good</strong> integers containing <code>n</code> digits.</p>
<p><strong>Note</strong> that <em>any</em> integer must <strong>not</strong> have leading zeros, <strong>neither</strong> before <strong>nor</strong> after rearrangement. For example, 1010 <em>cannot</em> be rearranged to form 101.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 3, k = 5</span></p>
<p><strong>Output:</strong> <span class="example-io">27</span></p>
<p><strong>Explanation:</strong></p>
<p><em>Some</em> of the good integers are:</p>
<ul>
<li>551 because it can be rearranged to form 515.</li>
<li>525 because it is already k-palindromic.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 1, k = 4</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The two good integers are 4 and 8.</p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 5, k = 6</span></p>
<p><strong>Output:</strong> <span class="example-io">2468</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10</code></li>
<li><code>1 &lt;= k &lt;= 9</code></li>
</ul>

@ -0,0 +1,39 @@
<p>You are given an array of integers <code>start</code> and an integer <code>d</code>, representing <code>n</code> intervals <code>[start[i], start[i] + d]</code>.</p>
<p>You are asked to choose <code>n</code> integers where the <code>i<sup>th</sup></code> integer must belong to the <code>i<sup>th</sup></code> interval. The <strong>score</strong> of the chosen integers is defined as the <strong>minimum</strong> absolute difference between any two integers that have been chosen.</p>
<p>Return the <strong>maximum</strong> <em>possible score</em> of the chosen integers.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">start = [6,0,3], d = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">4</span></p>
<p><strong>Explanation:</strong></p>
<p>The maximum possible score can be obtained by choosing integers: 8, 0, and 4. The score of these chosen integers is <code>min(|8 - 0|, |8 - 4|, |0 - 4|)</code> which equals 4.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">start = [2,6,13,13], d = 5</span></p>
<p><strong>Output:</strong> <span class="example-io">5</span></p>
<p><strong>Explanation:</strong></p>
<p>The maximum possible score can be obtained by choosing integers: 2, 7, 13, and 18. The score of these chosen integers is <code>min(|2 - 7|, |2 - 13|, |2 - 18|, |7 - 13|, |7 - 18|, |13 - 18|)</code> which equals 5.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= start.length &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= start[i] &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= d &lt;= 10<sup>9</sup></code></li>
</ul>

@ -0,0 +1,49 @@
<p>You are given a 2D matrix <code>grid</code> consisting of positive integers.</p>
<p>You have to select <em>one or more</em> cells from the matrix such that the following conditions are satisfied:</p>
<ul>
<li>No two selected cells are in the <strong>same</strong> row of the matrix.</li>
<li>The values in the set of selected cells are <strong>unique</strong>.</li>
</ul>
<p>Your score will be the <strong>sum</strong> of the values of the selected cells.</p>
<p>Return the <strong>maximum</strong> score you can achieve.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[1,2,3],[4,3,2],[1,1,1]]</span></p>
<p><strong>Output:</strong> <span class="example-io">8</span></p>
<p><strong>Explanation:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/29/grid1drawio.png" /></p>
<p>We can select the cells with values 1, 3, and 4 that are colored above.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[8,7,6],[8,3,2]]</span></p>
<p><strong>Output:</strong> <span class="example-io">15</span></p>
<p><strong>Explanation:</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/29/grid8_8drawio.png" style="width: 170px; height: 114px;" /></p>
<p>We can select the cells with values 7 and 8 that are colored above.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= grid.length, grid[i].length &lt;= 10</code></li>
<li><code>1 &lt;= grid[i][j] &lt;= 100</code></li>
</ul>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,43 @@
<p>You are given two strings, <code>coordinate1</code> and <code>coordinate2</code>, representing the coordinates of a square on an <code>8 x 8</code> chessboard.</p>
<p>Below is the chessboard for reference.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/07/17/screenshot-2021-02-20-at-22159-pm.png" style="width: 400px; height: 396px;" /></p>
<p>Return <code>true</code> if these two squares have the same color and <code>false</code> otherwise.</p>
<p>The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first (indicating its column), and the number second (indicating its row).</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinate1 = &quot;a1&quot;, coordinate2 = &quot;c3&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>Both squares are black.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinate1 = &quot;a1&quot;, coordinate2 = &quot;h3&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">false</span></p>
<p><strong>Explanation:</strong></p>
<p>Square <code>&quot;a1&quot;</code> is black and <code>&quot;h3&quot;</code> is white.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>coordinate1.length == coordinate2.length == 2</code></li>
<li><code>&#39;a&#39; &lt;= coordinate1[0], coordinate2[0] &lt;= &#39;h&#39;</code></li>
<li><code>&#39;1&#39; &lt;= coordinate1[1], coordinate2[1] &lt;= &#39;8&#39;</code></li>
</ul>

@ -0,0 +1,39 @@
<p>You are given a string <code>date</code> representing a Gregorian calendar date in the <code>yyyy-mm-dd</code> format.</p>
<p><code>date</code> can be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down in <code>year-month-day</code> format.</p>
<p>Return the <strong>binary</strong> representation of <code>date</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">date = &quot;2080-02-29&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;100000100000-10-11101&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p><span class="example-io">100000100000, 10, and 11101 are the binary representations of 2080, 02, and 29 respectively.</span></p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">date = &quot;1900-01-01&quot;</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;11101101100-1-1&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p><span class="example-io">11101101100, 1, and 1 are the binary representations of 1900, 1, and 1 respectively.</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>date.length == 10</code></li>
<li><code>date[4] == date[7] == &#39;-&#39;</code>, and all other <code>date[i]</code>&#39;s are digits.</li>
<li>The input is generated such that <code>date</code> represents a valid Gregorian calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>st</sup>, 2100 (both inclusive).</li>
</ul>

@ -0,0 +1,62 @@
<p>You are given an <code>m x n</code> binary matrix <code>grid</code> and an integer <code>health</code>.</p>
<p>You start on the upper-left corner <code>(0, 0)</code> and would like to get to the lower-right corner <code>(m - 1, n - 1)</code>.</p>
<p>You can move up, down, left, or right from one cell to another adjacent cell as long as your health <em>remains</em> <strong>positive</strong>.</p>
<p>Cells <code>(i, j)</code> with <code>grid[i][j] = 1</code> are considered <strong>unsafe</strong> and reduce your health by 1.</p>
<p>Return <code>true</code> if you can reach the final cell with a health value of 1 or more, and <code>false</code> otherwise.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]], health = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>The final cell can be reached safely by walking along the gray cells below.</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_1drawio.png" style="width: 301px; height: 121px;" /></div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[0,1,1,0,0,0],[1,0,1,0,0,0],[0,1,1,1,0,1],[0,0,1,0,1,0]], health = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">false</span></p>
<p><strong>Explanation:</strong></p>
<p>A minimum of 4 health points is needed to reach the final cell safely.</p>
<img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_2drawio.png" style="width: 361px; height: 161px;" /></div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">grid = [[1,1,1],[1,0,1],[1,1,1]], health = 5</span></p>
<p><strong>Output:</strong> <span class="example-io">true</span></p>
<p><strong>Explanation:</strong></p>
<p>The final cell can be reached safely by walking along the gray cells below.</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/08/04/3868_examples_3drawio.png" style="width: 181px; height: 121px;" /></p>
<p>Any path that does not go through the cell <code>(1, 1)</code> is unsafe since your health will drop to 0 when reaching the final cell.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 50</code></li>
<li><code><font face="monospace">2 &lt;= m * n</font></code></li>
<li><code>1 &lt;= health &lt;= m + n</code></li>
<li><code>grid[i][j]</code> is either 0 or 1.</li>
</ul>

@ -0,0 +1,46 @@
<p>There are <code>n</code> mountains in a row, and each mountain has a height. You are given an integer array <code>height</code> where <code>height[i]</code> represents the height of mountain <code>i</code>, and an integer <code>threshold</code>.</p>
<p>A mountain is called <strong>stable</strong> if the mountain just before it (<strong>if it exists</strong>) has a height <strong>strictly greater</strong> than <code>threshold</code>. <strong>Note</strong> that mountain 0 is <strong>not</strong> stable.</p>
<p>Return an array containing the indices of <em>all</em> <strong>stable</strong> mountains in <strong>any</strong> order.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [1,2,3,4,5], threshold = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">[3,4]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Mountain 3 is stable because <code>height[2] == 3</code> is greater than <code>threshold == 2</code>.</li>
<li>Mountain 4 is stable because <code>height[3] == 4</code> is greater than <code>threshold == 2</code>.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [10,1,10,1,10], threshold = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">[1,3]</span></p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">height = [10,1,10,1,10], threshold = 10</span></p>
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= n == height.length &lt;= 100</code></li>
<li><code>1 &lt;= height[i] &lt;= 100</code></li>
<li><code>1 &lt;= threshold &lt;= 100</code></li>
</ul>

@ -0,0 +1,60 @@
<p>You are given two <strong>positive</strong> integers <code>n</code> and <code>k</code>.</p>
<p>An integer <code>x</code> is called <strong>k-palindromic</strong> if:</p>
<ul>
<li><code>x</code> is a <span data-keyword="palindrome-integer">palindrome</span>.</li>
<li><code>x</code> is divisible by <code>k</code>.</li>
</ul>
<p>An integer is called <strong>good</strong> if its digits can be <em>rearranged</em> to form a <strong>k-palindromic</strong> integer. For example, for <code>k = 2</code>, 2020 can be rearranged to form the <em>k-palindromic</em> integer 2002, whereas 1010 cannot be rearranged to form a <em>k-palindromic</em> integer.</p>
<p>Return the count of <strong>good</strong> integers containing <code>n</code> digits.</p>
<p><strong>Note</strong> that <em>any</em> integer must <strong>not</strong> have leading zeros, <strong>neither</strong> before <strong>nor</strong> after rearrangement. For example, 1010 <em>cannot</em> be rearranged to form 101.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 3, k = 5</span></p>
<p><strong>Output:</strong> <span class="example-io">27</span></p>
<p><strong>Explanation:</strong></p>
<p><em>Some</em> of the good integers are:</p>
<ul>
<li>551 because it can be rearranged to form 515.</li>
<li>525 because it is already k-palindromic.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 1, k = 4</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The two good integers are 4 and 8.</p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 5, k = 6</span></p>
<p><strong>Output:</strong> <span class="example-io">2468</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10</code></li>
<li><code>1 &lt;= k &lt;= 9</code></li>
</ul>

@ -0,0 +1,55 @@
<p>You are given three <strong>positive</strong> integers <code>num1</code>, <code>num2</code>, and <code>num3</code>.</p>
<p>The <code>key</code> of <code>num1</code>, <code>num2</code>, and <code>num3</code> is defined as a four-digit number such that:</p>
<ul>
<li>Initially, if any number has <strong>less than</strong> four digits, it is padded with <strong>leading zeros</strong>.</li>
<li>The <code>i<sup>th</sup></code> digit (<code>1 &lt;= i &lt;= 4</code>) of the <code>key</code> is generated by taking the <strong>smallest</strong> digit among the <code>i<sup>th</sup></code> digits of <code>num1</code>, <code>num2</code>, and <code>num3</code>.</li>
</ul>
<p>Return the <code>key</code> of the three numbers <strong>without</strong> leading zeros (<em>if any</em>).</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 1, num2 = 10, num3 = 1000</span></p>
<p><strong>Output:</strong> <span class="example-io">0</span></p>
<p><strong>Explanation:</strong></p>
<p>On padding, <code>num1</code> becomes <code>&quot;0001&quot;</code>, <code>num2</code> becomes <code>&quot;0010&quot;</code>, and <code>num3</code> remains <code>&quot;1000&quot;</code>.</p>
<ul>
<li>The <code>1<sup>st</sup></code> digit of the <code>key</code> is <code>min(0, 0, 1)</code>.</li>
<li>The <code>2<sup>nd</sup></code> digit of the <code>key</code> is <code>min(0, 0, 0)</code>.</li>
<li>The <code>3<sup>rd</sup></code> digit of the <code>key</code> is <code>min(0, 1, 0)</code>.</li>
<li>The <code>4<sup>th</sup></code> digit of the <code>key</code> is <code>min(1, 0, 0)</code>.</li>
</ul>
<p>Hence, the <code>key</code> is <code>&quot;0000&quot;</code>, i.e. 0.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 987, num2 = 879, num3 = 798</span></p>
<p><strong>Output:</strong> <span class="example-io">777</span></p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num1 = 1, num2 = 2, num3 = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">1</span></p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= num1, num2, num3 &lt;= 9999</code></li>
</ul>

@ -0,0 +1,43 @@
<p>You are given an integer array <code>nums</code> and a <strong>positive</strong> integer <code>k</code>.</p>
<p>The <strong>value</strong> of a sequence <code>seq</code> of size <code>2 * x</code> is defined as:</p>
<ul>
<li><code>(seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1])</code>.</li>
</ul>
<p>Return the <strong>maximum</strong> <strong>value</strong> of any <span data-keyword="subsequence-array">subsequence</span> of <code>nums</code> having size <code>2 * k</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [2,6,7], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">5</span></p>
<p><strong>Explanation:</strong></p>
<p>The subsequence <code>[2, 7]</code> has the maximum value of <code>2 XOR 7 = 5</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,2,5,6,7], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p>The subsequence <code>[4, 5, 6, 7]</code> has the maximum value of <code>(4 OR 5) XOR (6 OR 7) = 2</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= nums.length &lt;= 400</code></li>
<li><code>1 &lt;= nums[i] &lt; 2<sup>7</sup></code></li>
<li><code>1 &lt;= k &lt;= nums.length / 2</code></li>
</ul>

@ -0,0 +1,52 @@
<p>You are given a string <code>s</code> of length <code>n</code> and an integer <code>k</code>, where <code>n</code> is a <strong>multiple</strong> of <code>k</code>. Your task is to hash the string <code>s</code> into a new string called <code>result</code>, which has a length of <code>n / k</code>.</p>
<p>First, divide <code>s</code> into <code>n / k</code> <strong><span data-keyword="substring-nonempty">substrings</span></strong>, each with a length of <code>k</code>. Then, initialize <code>result</code> as an <strong>empty</strong> string.</p>
<p>For each <strong>substring</strong> in order from the beginning:</p>
<ul>
<li>The <strong>hash value</strong> of a character is the index of that characte<!-- notionvc: 4b67483a-fa95-40b6-870d-2eacd9bc18d8 -->r in the <strong>English alphabet</strong> (e.g., <code>&#39;a&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 0</code>, <code>&#39;b&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 1</code>, ..., <code>&#39;z&#39; &rarr;<!-- notionvc: d3f8e4c2-23cd-41ad-a14b-101dfe4c5aba --> 25</code>).</li>
<li>Calculate the <em>sum</em> of all the <strong>hash values</strong> of the characters in the substring.</li>
<li>Find the remainder of this sum when divided by 26, which is called <code>hashedChar</code>.</li>
<li>Identify the character in the English lowercase alphabet that corresponds to <code>hashedChar</code>.</li>
<li>Append that character to the end of <code>result</code>.</li>
</ul>
<p>Return <code>result</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;abcd&quot;, k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;bf&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p>First substring: <code>&quot;ab&quot;</code>, <code>0 + 1 = 1</code>, <code>1 % 26 = 1</code>, <code>result[0] = &#39;b&#39;</code>.</p>
<p>Second substring: <code>&quot;cd&quot;</code>, <code>2 + 3 = 5</code>, <code>5 % 26 = 5</code>, <code>result[1] = &#39;f&#39;</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;mxz&quot;, k = 3</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;i&quot;</span></p>
<p><strong>Explanation:</strong></p>
<p>The only substring: <code>&quot;mxz&quot;</code>, <code>12 + 23 + 25 = 60</code>, <code>60 % 26 = 8</code>, <code>result[0] = &#39;i&#39;</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= k &lt;= 100</code></li>
<li><code>k &lt;= s.length &lt;= 1000</code></li>
<li><code>s.length</code> is divisible by <code>k</code>.</li>
<li><code>s</code> consists only of lowercase English letters.</li>
</ul>

@ -0,0 +1,60 @@
<p>There is an infinite 2D plane.</p>
<p>You are given a positive integer <code>k</code>. You are also given a 2D array <code>queries</code>, which contains the following queries:</p>
<ul>
<li><code>queries[i] = [x, y]</code>: Build an obstacle at coordinate <code>(x, y)</code> in the plane. It is guaranteed that there is <strong>no</strong> obstacle at this coordinate when this query is made.</li>
</ul>
<p>After each query, you need to find the <strong>distance</strong> of the <code>k<sup>th</sup></code> <strong>nearest</strong> obstacle from the origin.</p>
<p>Return an integer array <code>results</code> where <code>results[i]</code> denotes the <code>k<sup>th</sup></code> nearest obstacle after query <code>i</code>, or <code>results[i] == -1</code> if there are less than <code>k</code> obstacles.</p>
<p><strong>Note</strong> that initially there are <strong>no</strong> obstacles anywhere.</p>
<p>The <strong>distance</strong> of an obstacle at coordinate <code>(x, y)</code> from the origin is given by <code>|x| + |y|</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">queries = [[1,2],[3,4],[2,3],[-3,0]], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">[-1,7,5,3]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>Initially, there are 0 obstacles.</li>
<li>After <code>queries[0]</code>, there are less than 2 obstacles.</li>
<li>After <code>queries[1]</code>, there are obstacles at distances 3 and 7.</li>
<li>After <code>queries[2]</code>, there are obstacles at distances 3, 5, and 7.</li>
<li>After <code>queries[3]</code>, there are obstacles at distances 3, 3, 5, and 7.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">queries = [[5,5],[4,4],[3,3]], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">[10,8,6]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>After <code>queries[0]</code>, there is an obstacle at distance 10.</li>
<li>After <code>queries[1]</code>, there are obstacles at distances 8 and 10.</li>
<li>After <code>queries[2]</code>, there are obstacles at distances 6, 8, and 10.</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= queries.length &lt;= 2 * 10<sup>5</sup></code></li>
<li>All <code>queries[i]</code> are unique.</li>
<li><code>-10<sup>9</sup> &lt;= queries[i][0], queries[i][1] &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>

@ -0,0 +1,48 @@
<p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 &lt;= k &lt; n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <strong>increasing path</strong> of length <code>m</code> is defined as a list of points <code>(x<sub>1</sub>, y<sub>1</sub>)</code>, <code>(x<sub>2</sub>, y<sub>2</sub>)</code>, <code>(x<sub>3</sub>, y<sub>3</sub>)</code>, ..., <code>(x<sub>m</sub>, y<sub>m</sub>)</code> such that:</p>
<ul>
<li><code>x<sub>i</sub> &lt; x<sub>i + 1</sub></code> and <code>y<sub>i</sub> &lt; y<sub>i + 1</sub></code> for all <code>i</code> where <code>1 &lt;= i &lt; m</code>.</li>
<li><code>(x<sub>i</sub>, y<sub>i</sub>)</code> is in the given coordinates for all <code>i</code> where <code>1 &lt;= i &lt;= m</code>.</li>
</ul>
<p>Return the <strong>maximum</strong> length of an <strong>increasing path</strong> that contains <code>coordinates[k]</code>.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinates = [[3,1],[2,2],[4,1],[0,0],[5,3]], k = 1</span></p>
<p><strong>Output:</strong> <span class="example-io">3</span></p>
<p><strong>Explanation:</strong></p>
<p><code>(0, 0)</code>, <code>(2, 2)</code>, <code>(5, 3)</code><!-- notionvc: 082cee9e-4ce5-4ede-a09d-57001a72141d --> is the longest increasing path that contains <code>(2, 2)</code>.</p>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">coordinates = [[2,1],[7,0],[5,6]], k = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">2</span></p>
<p><strong>Explanation:</strong></p>
<p><code>(2, 1)</code>, <code>(5, 6)</code> is the longest increasing path that contains <code>(5, 6)</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= n == coordinates.length &lt;= 10<sup>5</sup></code></li>
<li><code>coordinates[i].length == 2</code></li>
<li><code>0 &lt;= coordinates[i][0], coordinates[i][1] &lt;= 10<sup>9</sup></code></li>
<li>All elements in <code>coordinates</code> are <strong>distinct</strong>.<!-- notionvc: 6e412fc2-f9dd-4ba2-b796-5e802a2b305a --><!-- notionvc: c2cf5618-fe99-4909-9b4c-e6b068be22a6 --></li>
<li><code>0 &lt;= k &lt;= n - 1</code></li>
</ul>

Some files were not shown because too many files have changed in this diff Show More