LeetCode 'SQL 50' Challenge: Invalid Tweets & Replace Employee ID With The Unique Identifier (Problems 1683 & 1378)

Both LeetCode problems challenge you to manipulate data within a relational database using SQL. While seemingly similar, they focus on different aspects of data management: LeetCode 1683: Invalid Tweets deals with identifying and handling invalid data. You’ll write a query to find tweets with specific criteria that mark them as invalid. LeetCode 1378: Replace Employee ID With The Unique Identifier focuses on data transformation. Here, you’ll craft a query to replace existing employee IDs with a unique identifier within the database....

July 21, 2024 · 2 min

LeetCode 'SQL 50' Challenge: Big Countries & Article Views (Problems 595 & 1148)

Challenges are often not a matter of difficulty, but of consistency. Yesterday I published two solutions for the first ‘LeetCode SQL 50’ challenge. To improve efficiency, I’ve decided to combine these solutions into one post for every 2 or 3 problems going forward. LeetCode 595 - Big Countries [SQL 3/50] This question introduces a new concept: double filtering. Together, we’ll learn how to use it effectively: A country is big if:...

July 4, 2024 · 4 min

LeetCode 'SQL 50' Challenge: Find Customer Referee (Problem 584)

As mentioned before, I’m tackling the LeetCode SQL challenge. This week’s problem, however, is surprisingly simple, making me wonder if it’s worth a dedicated write-up. Find the names of the customer that are not referred by the customer with id = 2. Return the result table in any order. The result format is in the following example. Example 1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Input: Customer table: +----+------+------------+ | id | name | referee_id | +----+------+------------+ | 1 | Will | null | | 2 | Jane | null | | 3 | Alex | 2 | | 4 | Bill | null | | 5 | Zack | 1 | | 6 | Mark | 2 | +----+------+------------+ Output: +------+ | name | +------+ | Will | | Jane | | Bill | | Zack | +------+ Solution To avoid repeating myself from the previous post (link above), I want to clarify that filtering for null values requires the IS NULL operator, not the equals sign (=)....

July 3, 2024 · 2 min

LeetCode 'SQL 50' Challenge: Recyclable and Low Fat Products (Problem 1757)

Leetcode has a Study Plan that focuses on solving SQL problems. The basic plan contains 50 problems, and when you finish them, you are awarded a cool badge. In between my many university assignments, I decided to take on this challenge as a goal, and of course, I’ll share my thoughts with you. The first problem in the challenge is: Write a solution to find the ids of products that are both low fat and recyclable....

July 3, 2024 · 2 min