Accepted Candidates From the Interviews — LeetCode 2041 Python Solution
MediumLeetCode PremiumDatabase
- Problem
- #2041
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
SQL
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
SQL
+--------------+----------+
| 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
Python
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
| Measure | Complexity |
|---|---|
| Time | O(n log n) (typical) |
| Space | O(n) auxiliary |
Related problems
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.