Replace Employee ID With The Unique Identifier — LeetCode 1378 Python Solution
EasyDatabase
- Problem
- #1378
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
SQL
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
SQL
+---------------+---------+
| 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
Python
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
| Measure | Complexity |
|---|---|
| Time | O(n log n) (typical) |
| Space | O(n) auxiliary |
Related problems
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.