MediumNo. 2041LeetCode Premium
Accepted Candidates From the Interviews — LeetCode 2041 Python Solution
- Topics
- Database
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
Table: Candidates +--------------+----------+ | Column Name | Type | +--------------+----------+ | candidate_id | int | | name | varchar | | years_of_exp | int | | interview_id | int | +--------------+----------+ candidate_id is the primary key (column with unique values) for this table. Each row of this table indicates the name of a candidate, their number of years of experience, and their interview ID.Example
+--------------+----------+
| Column Name | Type |
+--------------+----------+
| candidate_id | int |
| name | varchar |
| years_of_exp | int |
| interview_id | int |
+--------------+----------+
candidate_id is the primary key (column with unique values) for this table.
Each row of this table indicates the name of a candidate, their number of years of experience, and their interview ID.Python solution
import pandas as pd
def accepted_candidates(candidates: pd.DataFrame, rounds: pd.DataFrame) -> pd.DataFrame:
merged_df = pd.merge(candidates, rounds, on="interview_id")
filtered_df = merged_df[merged_df["years_of_exp"] >= 2]
grouped_df = filtered_df.groupby("candidate_id").agg({"score": "sum"})
return grouped_df[grouped_df["score"] > 15].reset_index()[["candidate_id"]]Complexity
- Time
- O(n log n)(typical)
- Space · auxiliary
- O(n)
Related problems
| No. | Problem | Difficulty |
|---|---|---|
| 0175 | Combine Two Tables | Easy |
| 0176 | Second Highest Salary | Medium |
| 0177 | Nth Highest Salary | Medium |
| 0178 | Rank Scores | Medium |
| 0180 | Consecutive Numbers | Medium |
| 0181 | Employees Earning More Than Their Managers | Easy |
Frequently asked questions
- How hard is LeetCode 2041. Accepted Candidates From the Interviews?
LeetCode 2041. Accepted Candidates From the Interviews is rated Medium on LeetCode.
- What topics does LeetCode 2041. Accepted Candidates From the Interviews cover?
LeetCode 2041. Accepted Candidates From the Interviews is tagged Database on LeetCode.
- Is LeetCode 2041. Accepted Candidates From the Interviews a premium problem?
Yes. LeetCode 2041. Accepted Candidates From the Interviews is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.