How bitsbybhargav/leetcode works
1. This repository is a LeetCode SQL solutions collection, not an application with a runtime service. Each top-level folder corresponds to one database problem and is intended to be solved independently.
2. The main architectural unit is the problem directory. For example, 175-combine-two-tables/, 176-second-highest-salary/, and 184-department-highest-salary/ each contain a problem-specific README.md and a single .sql solution file.
3. The root README.md is minimal and only labels the repository as “LeetCode,” so there is no central product documentation, shared design, or orchestration layer.
4. There is no shared library code, common schema module, or cross-folder dependency graph. Each SQL file stands alone and targets the schema described by its own LeetCode prompt.
5. The primary data flow in every module is:
input tables defined by the challenge -> SQL query or DML statement -> result set or updated table expected by LeetCode.
There is no persistent application state beyond the database tables used in each exercise.
6. The repository includes both read-only analytics queries and data modification queries. Examples include selection/reporting problems like 1174-sales-analysis-iii.sql and mutation-oriented problems like 196-delete-duplicate-emails.sql and 627-swap-sex-of-employees.sql.
7. The problem set spans common SQL patterns and relational boundaries: joins, grouping, ranking, deduplication, subqueries, window-like logic, and conditional filtering. Many files encode one focused query strategy per problem rather than a multi-step pipeline.
8. Directory names are prefixed with the LeetCode problem ID, which makes the structure stable and easy to map back to the original prompt. This also suggests the intended architecture for navigation is by problem number, not by feature area.
9. The README.md inside each problem folder likely mirrors the problem statement and acts as local context for the corresponding SQL file. In architectural terms, the README is documentation boundary, while the .sql file is the implementation boundary.
10. There is no visible build system, test harness, package manager, container setup, or deployment infrastructure in this repository snapshot. The execution environment is effectively the LeetCode SQL engine or any compatible SQL dialect used to validate the solution.
11. Because the repository is a set of independent exercises, the best diagram is a hub-and-spoke or flat catalog view: one root repository containing many isolated problem modules, each with documentation and a single query artifact.
12. If you are drawing the architecture, the key labels should be “problem specification,” “SQL solution,” and “database tables/result set,” with no downstream services, API layer, or shared backend components.
Main entry points: combine-two-tables.sql Combine tables · department-highest-salary.sql Dept top salary · department-top-three-salaries.sql Dept top three · delete-duplicate-emails.sql Delete duplicates
Components 23
Repository
Top-level LeetCode SQL catalog.
- LeetCode · Minimal repository README.
README.md - Problem catalog · Flat set of numbered SQL exercises.
- Problem spec · Per-problem README describing the challenge and schema.
- SQL solution · Standalone SQL file implementing the answer for a single problem.
- Tables / result · Input tables from the prompt and the expected result set or update.
Problem modules
Independent LeetCode exercises, each with local spec and one solution file.
- Combine tables · Find employees enriched with department/company data.
175-combine-two-tables/README.md - Combine tables · Join-based query for the two tables exercise.
175-combine-two-tables/combine-two-tables.sql - Dept top salary · Return the highest-paid employee per department.
184-department-highest-salary/README.md - Dept top salary · Ranking/join query for department-level maxima.
184-department-highest-salary/department-highest-salary.sql - Dept top three · Return the top three salaries per department.
185-department-top-three-salaries/README.md - Dept top three · Per-group ranking query with salary cutoff logic.
185-department-top-three-salaries/department-top-three-salaries.sql - Delete duplicates · Remove duplicate emails while keeping one row.
196-delete-duplicate-emails/README.md - Delete duplicates · Mutation-oriented statement for deduplication.
196-delete-duplicate-emails/delete-duplicate-emails.sql - Rising temperature · Find days with a higher temperature than the previous day.
197-rising-temperature/README.md - Rising temperature · Self-join or date-difference query over weather rows.
197-rising-temperature/rising-temperature.sql - Direct reports · Identify managers with at least five reports.
570-managers-with-at-least-5-direct-reports/README.md - Direct reports · Aggregation over employee-manager relationships.
570-managers-with-at-least-5-direct-reports/managers-with-at-least-5-direct-reports.sql - Sales person · Exclude salespeople tied to a banned customer.
607-sales-person/README.md - Sales person · Anti-join / exclusion query across sales tables.
607-sales-person/sales-person.sql - Not boring · Filter movies by odd ID and a text constraint.
620-not-boring-movies/README.md - Not boring · Conditional filter over movie rows.
620-not-boring-movies/not-boring-movies.sql - Swap sex · Update employee sex values in place.
627-swap-sex-of-employees/README.md - Swap sex · In-place mutation using conditional update logic.
627-swap-sex-of-employees/swap-sex-of-employees.sql
Connections 22
- LeetCode → Problem catalog: describes · Repository README names the collection; problem catalog holds the actual content.
- Problem catalog → Problem spec: organizes · Each problem directory provides local challenge context.
- Problem spec → SQL solution: guides · The README boundary leads to the standalone SQL implementation.
- SQL solution → Tables / result: reads/writes · Queries consume challenge tables and produce a result set or update rows.
- Combine tables → Combine tables: specifies · Local prompt documents the join task implemented by the SQL file.
- Combine tables → Tables / result: joins · Two-table exercise produces combined rows.
- Dept top salary → Dept top salary: specifies · Department-level salary prompt maps to one SQL solution.
- Dept top salary → Tables / result: ranks · Produces highest-paid employee rows from relational input.
- Dept top three → Dept top three: specifies · Top-three-per-department prompt maps to one SQL solution.
- Dept top three → Tables / result: ranks · Produces departmental top-N rows from input tables.
- Delete duplicates → Delete duplicates: specifies · Duplicate-removal prompt maps to an update/delete statement.
- Delete duplicates → Tables / result: mutates · Solution updates or removes duplicate rows in place.
- Rising temperature → Rising temperature: specifies · Weather prompt maps to a date-based query.
- Rising temperature → Tables / result: filters · Produces rows matching the temperature increase condition.
- Direct reports → Direct reports: specifies · Manager-count prompt maps to an aggregate query.
- Direct reports → Tables / result: aggregates · Counts direct reports per manager.
- Sales person → Sales person: specifies · Sales exclusion prompt maps to an anti-join query.
- Sales person → Tables / result: excludes · Filters out salespeople linked to disallowed customers.
- Not boring → Not boring: specifies · Movie filter prompt maps to a conditional select.
- Not boring → Tables / result: filters · Returns only rows that satisfy the odd-id/title constraints.
- Swap sex → Swap sex: specifies · Swap prompt maps to an in-place update.
- Swap sex → Tables / result: mutates · Updates employee sex values directly.