EasyNo. 1378
Replace Employee ID With The Unique Identifier — LeetCode 1378 Python Solution
- Topics
- Database
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
Table: Employees +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | +---------------+---------+ id is the primary key (column with unique values) for this table. Each row of this table contains the id and the name of an employee in a company.Example
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| id | int |
| name | varchar |
+---------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table contains the id and the name of an employee in a company.Python solution
import duckdb
import pandas as pd
def solution(employees: pd.DataFrame, employee_uni: pd.DataFrame) -> pd.DataFrame:
con = duckdb.connect()
con.register("Employees", employees)
con.register("EmployeeUNI", employee_uni)
return con.execute("""SELECT unique_id, name
FROM
Employees
LEFT JOIN EmployeeUNI USING (id);""").df()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 1378. Replace Employee ID With The Unique Identifier?
LeetCode 1378. Replace Employee ID With The Unique Identifier is rated Easy on LeetCode.
- What topics does LeetCode 1378. Replace Employee ID With The Unique Identifier cover?
LeetCode 1378. Replace Employee ID With The Unique Identifier is tagged Database on LeetCode.