diff --git a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README.md b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README.md index b7dc7b03596aa..907de5036c28b 100644 --- a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README.md +++ b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README.md @@ -314,7 +314,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => { @@ -370,7 +370,7 @@ var getDirections = function (root, startValue, destValue) { const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node, x, path) => { diff --git a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README_EN.md b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README_EN.md index 41a9811d4e980..58782483df639 100644 --- a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README_EN.md +++ b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/README_EN.md @@ -310,7 +310,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => { @@ -366,7 +366,7 @@ var getDirections = function (root, startValue, destValue) { const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node, x, path) => { diff --git a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.js b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.js index c6ca93d60610d..cf11074f0553b 100644 --- a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.js +++ b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.js @@ -20,7 +20,7 @@ var getDirections = function (root, startValue, destValue) { const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node, x, path) => { diff --git a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.ts b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.ts index fa2f24e5d72b9..5c028830da797 100644 --- a/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.ts +++ b/solution/2000-2099/2096.Step-By-Step Directions From a Binary Tree Node to Another/Solution.ts @@ -20,7 +20,7 @@ function getDirections(root: TreeNode | null, startValue: number, destValue: num const left = lca(node.left, p, q); const right = lca(node.right, p, q); - return left && right ? node : left ?? right; + return left && right ? node : (left ?? right); }; const dfs = (node: TreeNode | null, x: number, path: string[]): boolean => { diff --git a/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/README.md b/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/README.md index 6854118c4541a..6631f19ba30cd 100644 --- a/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/README.md +++ b/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/README.md @@ -66,6 +66,10 @@ startDate = 2022-03-08, endDate = 2022-03-20, minAmount = 1000 - 用户 2 在时间间隔内有一次购买,但金额小于 minAmount。 - 用户 3 是唯一一个购买行为同时满足这两个条件的用户。 +
+ +
重要提示:此问题与 2230. 查找可享受优惠的用户 基本相同。
+ ## 解法 diff --git a/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md b/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md new file mode 100644 index 0000000000000..c8fcb9c764b8e --- /dev/null +++ b/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md @@ -0,0 +1,197 @@ +--- +comments: true +difficulty: 中等 +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README.md +tags: + - 数据库 +--- + + + +# [3278. Find Candidates for Data Scientist Position II 🔒](https://leetcode.cn/problems/find-candidates-for-data-scientist-position-ii) + +[English Version](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README_EN.md) + +## 题目描述 + + + +Table: Candidates
++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| candidate_id | int | +| skill | varchar | +| proficiency | int | ++--------------+---------+ +(candidate_id, skill) is the unique key for this table. +Each row includes candidate_id, skill, and proficiency level (1-5). ++ +
Table: Projects
++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| project_id | int | +| skill | varchar | +| importance | int | ++--------------+---------+ +(project_id, skill) is the primary key for this table. +Each row includes project_id, required skill, and its importance (1-5) for the project. ++ +
Leetcode is staffing for multiple data science projects. Write a solution to find the best candidate for each project based on the following criteria:
+ +100
points10
points for each skill where proficiency > importance5
points for each skill where proficiency < importanceInclude only the top candidate (highest score) for each project. If there’s a tie, choose the candidate with the lower candidate_id
. If there is no suitable candidate for a project, do not return that project.
Return a result table ordered by project_id
in ascending order.
The result format is in the following example.
+ ++
Example:
+ +Input:
+ +Candidates
table:
++--------------+-----------+-------------+ +| candidate_id | skill | proficiency | ++--------------+-----------+-------------+ +| 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
table:
++-------------+-----------+------------+ +| project_id | skill | importance | ++-------------+-----------+------------+ +| 501 | Python | 4 | +| 501 | Tableau | 3 | +| 501 | PostgreSQL| 5 | +| 502 | Python | 3 | +| 502 | Tableau | 4 | +| 502 | R | 2 | ++-------------+-----------+------------+ ++ +
Output:
+ +++-------------+--------------+-------+ +| project_id | candidate_id | score | ++-------------+--------------+-------+ +| 501 | 101 | 105 | +| 502 | 102 | 130 | ++-------------+--------------+-------+ ++ +
Explanation:
+ +The output table is ordered by project_id in ascending order.
+Table: Candidates
++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| candidate_id | int | +| skill | varchar | +| proficiency | int | ++--------------+---------+ +(candidate_id, skill) is the unique key for this table. +Each row includes candidate_id, skill, and proficiency level (1-5). ++ +
Table: Projects
++--------------+---------+ +| Column Name | Type | ++--------------+---------+ +| project_id | int | +| skill | varchar | +| importance | int | ++--------------+---------+ +(project_id, skill) is the primary key for this table. +Each row includes project_id, required skill, and its importance (1-5) for the project. ++ +
Leetcode is staffing for multiple data science projects. Write a solution to find the best candidate for each project based on the following criteria:
+ +100
points10
points for each skill where proficiency > importance5
points for each skill where proficiency < importanceInclude only the top candidate (highest score) for each project. If there’s a tie, choose the candidate with the lower candidate_id
. If there is no suitable candidate for a project, do not return that project.
Return a result table ordered by project_id
in ascending order.
The result format is in the following example.
+ ++
Example:
+ +Input:
+ +Candidates
table:
++--------------+-----------+-------------+ +| candidate_id | skill | proficiency | ++--------------+-----------+-------------+ +| 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
table:
++-------------+-----------+------------+ +| project_id | skill | importance | ++-------------+-----------+------------+ +| 501 | Python | 4 | +| 501 | Tableau | 3 | +| 501 | PostgreSQL| 5 | +| 502 | Python | 3 | +| 502 | Tableau | 4 | +| 502 | R | 2 | ++-------------+-----------+------------+ ++ +
Output:
+ +++-------------+--------------+-------+ +| project_id | candidate_id | score | ++-------------+--------------+-------+ +| 501 | 101 | 105 | +| 502 | 102 | 130 | ++-------------+--------------+-------+ ++ +
Explanation:
+ +The output table is ordered by project_id in ascending order.
+