Friendly Movies Streamed Last Month — LeetCode 1495 Python Solution
EasyLeetCode PremiumDatabase
- Problem
- #1495
- Reading time
- 3 min
- Source
- leetcode.com
Table schema
SQL
Table: TVProgram +---------------+---------+ | Column Name | Type | +---------------+---------+ | program_date | date | | content_id | int | | channel | varchar | +---------------+---------+ (program_date, content_id) is the primary key (combination of columns with unique values) for this table. This table contains information of the programs on the TV.Example
SQL
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| program_date | date |
| content_id | int |
| channel | varchar |
+---------------+---------+
(program_date, content_id) is the primary key (combination of columns with unique values) for this table.
This table contains information of the programs on the TV.
content_id is the id of the program in some channel on the TV.Python solution
Python
import duckdb
import pandas as pd
def solution(tvprogram: pd.DataFrame, content: pd.DataFrame) -> pd.DataFrame:
con = duckdb.connect()
con.register("TVProgram", tvprogram)
con.register("Content", content)
return con.execute("""SELECT DISTINCT title
FROM
TVProgram
JOIN Content USING (content_id)
WHERE
DATE_FORMAT(program_date, '%Y%m') = '202006'
AND kids_content = 'Y'
AND content_type = 'Movies';""").df()Complexity
| Measure | Complexity |
|---|---|
| Time | O(n log n) (typical) |
| Space | O(n) auxiliary |
Related problems
Frequently asked questions
- How hard is LeetCode 1495. Friendly Movies Streamed Last Month?
- LeetCode 1495. Friendly Movies Streamed Last Month is rated Easy on LeetCode.
- What topics does LeetCode 1495. Friendly Movies Streamed Last Month cover?
- LeetCode 1495. Friendly Movies Streamed Last Month is tagged Database on LeetCode.
- Is LeetCode 1495. Friendly Movies Streamed Last Month a premium problem?
- Yes. LeetCode 1495. Friendly Movies Streamed Last Month is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.