Sellers With No Sales — LeetCode 1607 Python Solution

EasyLeetCode PremiumDatabase
Problem
#1607
Reading time
3 min

Table schema

SQL
Table: Customer +---------------+---------+ | Column Name | Type | +---------------+---------+ | customer_id | int | | customer_name | varchar | +---------------+---------+ customer_id is the column with unique values for this table. Each row of this table contains the information of each customer in the WebStore.

Example

SQL
+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| customer_id   | int     |
| customer_name | varchar |
+---------------+---------+
customer_id is the column with unique values for this table.
Each row of this table contains the information of each customer in the WebStore.

Python solution

Python
import duckdb
import pandas as pd

def solution(customer: pd.DataFrame, orders: pd.DataFrame, seller: pd.DataFrame) -> pd.DataFrame:
    con = duckdb.connect()
    con.register("Customer", customer)
    con.register("Orders", orders)
    con.register("Seller", seller)
    return con.execute("""SELECT seller_name
FROM
    Seller
    LEFT JOIN Orders USING (seller_id)
GROUP BY seller_id
HAVING IFNULL(SUM(YEAR(sale_date) = 2020), 0) = 0
ORDER BY 1;""").df()

Complexity

MeasureComplexity
TimeO(n log n) (typical)
SpaceO(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 1607. Sellers With No Sales?
LeetCode 1607. Sellers With No Sales is rated Easy on LeetCode.
What topics does LeetCode 1607. Sellers With No Sales cover?
LeetCode 1607. Sellers With No Sales is tagged Database on LeetCode.
Is LeetCode 1607. Sellers With No Sales a premium problem?
Yes. LeetCode 1607. Sellers With No Sales is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview