MediumNo. 2298LeetCode Premium
Tasks Count in the Weekend — LeetCode 2298 Python Solution
- Topics
- Database
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
Table: Tasks +-------------+------+ | Column Name | Type | +-------------+------+ | task_id | int | | assignee_id | int | | submit_date | date | +-------------+------+ task_id is the primary key (column with unique values) for this table. Each row in this table contains the ID of a task, the id of the assignee, and the submission date.Example
+-------------+------+
| Column Name | Type |
+-------------+------+
| task_id | int |
| assignee_id | int |
| submit_date | date |
+-------------+------+
task_id is the primary key (column with unique values) for this table.
Each row in this table contains the ID of a task, the id of the assignee, and the submission date.Python solution
import duckdb
import pandas as pd
def solution(tasks: pd.DataFrame) -> pd.DataFrame:
con = duckdb.connect()
con.register("Tasks", tasks)
return con.execute("""SELECT
SUM(WEEKDAY(submit_date) IN (5, 6)) AS weekend_cnt,
SUM(WEEKDAY(submit_date) NOT IN (5, 6)) AS working_cnt
FROM Tasks;""").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 2298. Tasks Count in the Weekend?
LeetCode 2298. Tasks Count in the Weekend is rated Medium on LeetCode.
- What topics does LeetCode 2298. Tasks Count in the Weekend cover?
LeetCode 2298. Tasks Count in the Weekend is tagged Database on LeetCode.
- Is LeetCode 2298. Tasks Count in the Weekend a premium problem?
Yes. LeetCode 2298. Tasks Count in the Weekend is a LeetCode Premium problem, so the full statement and test cases require a paid LeetCode subscription.