Market Analysis II — LeetCode 1159 Python Solution

HardLeetCode PremiumDatabase
Problem
#1159
Reading time
2 min

Table schema

SQL
Table: Users +----------------+---------+ | Column Name | Type | +----------------+---------+ | user_id | int | | join_date | date | | favorite_brand | varchar | +----------------+---------+ user_id is the primary key (column with unique values) of this table. This table has the info of the users of an online shopping website where users can sell and buy items.

Example

SQL
+----------------+---------+
| Column Name    | Type    |
+----------------+---------+
| user_id        | int     |
| join_date      | date    |
| favorite_brand | varchar |
+----------------+---------+
user_id is the primary key (column with unique values) of this table.
This table has the info of the users of an online shopping website where users can sell and buy items.

Complexity

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

Related problems

Frequently asked questions

How hard is LeetCode 1159. Market Analysis II?
LeetCode 1159. Market Analysis II is rated Hard on LeetCode.
What topics does LeetCode 1159. Market Analysis II cover?
LeetCode 1159. Market Analysis II is tagged Database on LeetCode.
Is LeetCode 1159. Market Analysis II a premium problem?
Yes. LeetCode 1159. Market Analysis II 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