The LeetCode problem “Find Customer Referee” requires us to retrieve the names of customers who either have no referee or whose referee is not customer ID 2. High-Level Strategy To solve this problem: 1. Filter by Conditions: Use SQL’s WHERE clause to apply conditions that exclude customers with referee_id =…
Recyclable and Low Fat Products – 1757. LeetCode
The LeetCode problem “Recyclable and Low Fat Products” is a SQL problem where the object is to retrieve a list of products that are both recyclable and low fat from a database table. Each product has attributes indicating whether it is recyclable or low fat. Problem Objective Given a Products…
Combination Sum – 39. LeetCode
The LeetCode problem “Combination Sum” asks us to find all unique combinations of numbers from a given list (array) that sum up to a specified target. Each number in the array can be used multiple times in the combination. For example, given the array [2, 3, 6, 7] and a…
3Sum Closest – 16. LeetCode
The LeetCode problem “3Sum Closest” asks us to find three numbers in an array that sum up to a value closest to a given target. For example, given an array nums = [-1, 2, 1, -4] and target 1, the three numbers closest to the target are [-1, 2, 1],…
Subarray Sum Equals K – 560. LeetCode
In the “Subarray Sum Equals K” problem, you are given an array of integers and a target integer, k. The goal is to find the number of contiguous subarrays within the array that sum up to k. Think of it as searching for specific sections in the array where adding…
Longest Common Prefix – 14. LeetCode
The LeetCode problem “Longest Common Prefix” requires finding the longest common starting sequence (prefix) among an array of strings. For example, given [“flower”, “flow” “flight”], the longest common prefix is “fl”. Algorithm and Data Structure Choice Chosen Algorithm: Vertical Scanning The vertical scanning technique checks each character position across all…
Meeting Rooms II – 253. LeetCode
The LeetCode problem “Meeting Rooms II” requires us to determine the minimum number of meeting rooms needed to accommodate a set of meetings with a given start and end times. For example, if we have meetings scheduled from (0, 30), (5, 10), and (15, 20), we need two meeting rooms…
Trapping Rain Water – 42. LeetCode
To solve the LeetCode problem “Trapping Rain Water”, we’re given an array representing an elevation map, where each element’s value is the height of that point. The goal is to calculate how much water can be trapped between the bars after it rains. Think of each bar as a wall,…
Compare Version Numbers – 165. LeetCode
To solve the Compare Version Numbers problem, we need to compare version strings like “1.0.0 and “1.0.1”. Each string is split by . to represent levels of the version, such as major.minor.patch. Our task is to compare these levels and determine which version is larger or if they are equal….
Scaling Databases with Replication: Balancing Speed, Consistency, and Recovery
Database replication is the process of copying and storing data from one database (primary) to one or more other databases (secondary replicas). It ensures data availability, reliability, and performance across different servers or locations. Replication helps prevent data loss by having backups ready in case of system failure, ensures that…