# akshatsinghnayal/leetcode architecture

> Architecture diagram of the GitHub repository akshatsinghnayal/leetcode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akshatsinghnayal/leetcode
- Repository: https://github.com/akshatsinghnayal/leetcode

## Overview

1. This repository is a problem-solution archive, not an application. It primarily contains LeetCode and interview-practice answers, generated with LeetHub v2 and organized as a catalog of independent algorithm implementations.

2. The main top-level subsystem is the LeetCode collection: folders named by problem number and slug, such as `0001-two-sum`, `0207-course-schedule`, or `3946-maximum-number-of-items-from-sale-i`. Each folder is a self-contained solution unit.

3. Inside most LeetCode folders there are two artifacts:
   - a C++ source file with the same problem slug
   - a local `README.md` containing the problem statement or notes
   A few problems have only a README, indicating missing or not-yet-committed code.

4. The second major subsystem is a categorized interview-practice area under `Difficulty/`. This is split into `Basic`, `Easy`, `Medium`, and `Hard`, and then further into named problem folders. These are also independent solution units, but they follow a different naming scheme from the LeetCode-numbered archive.

5. The codebase is intentionally flat and modular at the folder level. There is no visible shared library, service layer, test harness, or cross-folder dependency graph. Architecture-wise, every folder stands alone and solves one problem in isolation.

6. Languages are problem-driven rather than system-driven. Most implementations are in C++, reflecting algorithmic interview practice. A small number of SQL problems are included as `.sql` files, which are separate from the C++ problem set and represent database-query solutions.

7. The repository root `README.md` acts as an index rather than documentation for a runtime system. It enumerates LeetCode topics and links each topic to the corresponding problem folder. This creates a taxonomy layer across the independent solutions.

8. The topic index is the most important “architecture” layer beyond folders. Problems are grouped by algorithmic patterns such as Array, String, Linked List, Tree, Graph, Dynamic Programming, Greedy, Heap, Binary Search, Stack, Sliding Window, and others. For a diagram, this is a many-to-many classification map from problem folders to topics.

9. Several problems appear under multiple topics, which is expected for algorithm exercises. For example, a single solution may belong to both “Tree” and “Depth-First Search,” or both “Array” and “Two Pointers.” The repository is therefore better modeled as a tagged solution corpus than a hierarchical app.

10. The `stats.json` file likely serves as repository metadata/summary generated by tooling rather than by the solutions themselves. It is a supporting artifact, not part of the solution execution path.

11. There is no runtime data flow between problems. The only real flow is external: LeetCode problem statement → local README/source file → optional metadata classification in the root README. No services, APIs, databases, or queues are part of the solution architecture.

12. The clean architectural boundary is therefore: problem folder = unit of implementation; root README = index and taxonomy; `Difficulty/` = alternate categorization for non-LeetCode practice; SQL files = separate query-solution branch. An accurate diagram should emphasize catalog structure, classification overlays, and the absence of shared execution dependencies.

Main entry points: [`README.md`](https://github.com/akshatsinghnayal/leetcode/blob/main/README.md) (Topic Index), [`Difficulty: Basic`](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Basic) (Difficulty/), [`Difficulty: Easy`](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Easy) (Easy), [`Difficulty: Medium`](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Medium) (Medium)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Repository Root"]
  node_readme["README.md<br/>root index<br/>[README.md]"]
  node_stats["stats.json<br/>metadata<br/>[stats.json]"]
  node_topics(("Topic Index<br/>taxonomy<br/>[README.md]"))
end

subgraph group_leetcode["LeetCode Archive"]
  node_leetcode_archive["LeetCode Archive<br/>catalog"]
  node_lc_array["Array/Hash<br/>topic cluster"]
  node_lc_two_pointers["Pointers<br/>topic cluster"]
  node_lc_list["Linked Lists<br/>topic cluster"]
  node_lc_tree["Trees<br/>topic cluster"]
  node_lc_graph["Graphs<br/>topic cluster"]
  node_lc_dp["DP<br/>topic cluster"]
end

subgraph group_difficulty["Interview Practice"]
  node_difficulty_root["Difficulty/<br/>practice catalog"]
  node_basic_cat["Basic<br/>difficulty band"]
  node_easy_cat["Easy<br/>difficulty band"]
  node_medium_cat["Medium<br/>difficulty band"]
  node_hard_cat["Hard<br/>difficulty band"]
  node_basic_unit["Odd or Even<br/>practice unit"]
  node_easy_unit["BFS Graph<br/>practice unit"]
  node_medium_unit["Knapsack<br/>practice unit"]
  node_hard_unit["LCS Sequences<br/>practice unit"]
end

subgraph group_sql["SQL Solutions"]
  node_lc_sql["SQL Branch<br/>query solutions"]
  node_sql_unit["Big Countries<br/>sql solution"]
end

node_readme -->|"indexes"| node_topics
node_readme -->|"links"| node_leetcode_archive
node_readme -->|"references"| node_difficulty_root
node_readme -->|"mentions"| node_lc_sql
node_stats -.->|"summarizes"| node_readme
node_topics -->|"tags"| node_lc_array
node_topics -->|"tags"| node_lc_two_pointers
node_topics -->|"tags"| node_lc_list
node_topics -->|"tags"| node_lc_tree
node_topics -->|"tags"| node_lc_graph
node_topics -->|"tags"| node_lc_dp
node_leetcode_archive -->|"contains"| node_lc_array
node_leetcode_archive -->|"contains"| node_lc_two_pointers
node_leetcode_archive -->|"contains"| node_lc_list
node_leetcode_archive -->|"contains"| node_lc_tree
node_leetcode_archive -->|"contains"| node_lc_graph
node_leetcode_archive -->|"contains"| node_lc_dp
node_difficulty_root -->|"organizes"| node_basic_cat
node_difficulty_root -->|"organizes"| node_easy_cat
node_difficulty_root -->|"organizes"| node_medium_cat
node_difficulty_root -->|"organizes"| node_hard_cat
node_basic_cat -->|"contains"| node_basic_unit
node_easy_cat -->|"contains"| node_easy_unit
node_medium_cat -->|"contains"| node_medium_unit
node_hard_cat -->|"contains"| node_hard_unit
node_lc_sql -->|"contains"| node_sql_unit

click node_readme "https://github.com/akshatsinghnayal/leetcode/blob/main/README.md"
click node_stats "https://github.com/akshatsinghnayal/leetcode/blob/main/stats.json"
click node_topics "https://github.com/akshatsinghnayal/leetcode/blob/main/README.md"
click node_lc_array "https://github.com/akshatsinghnayal/leetcode/tree/main/0001-two-sum"
click node_lc_two_pointers "https://github.com/akshatsinghnayal/leetcode/tree/main/0011-container-with-most-water"
click node_lc_list "https://github.com/akshatsinghnayal/leetcode/tree/main/0019-remove-nth-node-from-end-of-list"
click node_lc_tree "https://github.com/akshatsinghnayal/leetcode/tree/main/0094-binary-tree-inorder-traversal"
click node_lc_graph "https://github.com/akshatsinghnayal/leetcode/tree/main/0207-course-schedule"
click node_lc_dp "https://github.com/akshatsinghnayal/leetcode/tree/main/0120-triangle"
click node_lc_sql "https://github.com/akshatsinghnayal/leetcode/tree/main/0595-big-countries"
click node_difficulty_root "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Basic"
click node_basic_cat "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Basic"
click node_easy_cat "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Easy"
click node_medium_cat "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Medium"
click node_hard_cat "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Hard"
click node_basic_unit "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Basic/Odd or Even"
click node_easy_unit "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Easy/BFS of graph"
click node_medium_unit "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Medium/0 - 1 Knapsack Problem"
click node_hard_unit "https://github.com/akshatsinghnayal/leetcode/tree/main/Difficulty: Hard/Print all LCS sequences"
click node_sql_unit "https://github.com/akshatsinghnayal/leetcode/tree/main/0595-big-countries"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_readme,node_stats,node_topics toneBlue
class node_leetcode_archive,node_lc_array,node_lc_two_pointers,node_lc_list,node_lc_tree,node_lc_graph,node_lc_dp toneAmber
class node_difficulty_root,node_basic_cat,node_easy_cat,node_medium_cat,node_hard_cat,node_basic_unit,node_easy_unit,node_medium_unit,node_hard_unit toneMint
class node_lc_sql,node_sql_unit toneRose
```

## Components

### Repository Root

Top-level index and metadata files.

- [README.md](https://github.com/akshatsinghnayal/leetcode/blob/main/README.md): root index · Repository index and taxonomy entry point. · `README.md`
- [stats.json](https://github.com/akshatsinghnayal/leetcode/blob/main/stats.json): metadata · Generated repository summary data. · `stats.json`
- [Topic Index](https://github.com/akshatsinghnayal/leetcode/blob/main/README.md): taxonomy · Algorithm-pattern classification used to group solutions. · `README.md`

### LeetCode Archive

Numbered problem folders with independent algorithm solutions.

- **LeetCode Archive**: catalog · Flat archive of numbered problem folders.
- [Array/Hash](https://github.com/akshatsinghnayal/leetcode/tree/main/0001-two-sum): topic cluster · Representative set of array, hashing, and prefix-sum style problems. · `0001-two-sum`
- [Pointers](https://github.com/akshatsinghnayal/leetcode/tree/main/0011-container-with-most-water): topic cluster · Representative two-pointer and sliding-window style problems. · `0011-container-with-most-water`
- [Linked Lists](https://github.com/akshatsinghnayal/leetcode/tree/main/0019-remove-nth-node-from-end-of-list): topic cluster · Representative list-manipulation solutions. · `0019-remove-nth-node-from-end-of-list`
- [Trees](https://github.com/akshatsinghnayal/leetcode/tree/main/0094-binary-tree-inorder-traversal): topic cluster · Representative binary-tree and BST solutions. · `0094-binary-tree-inorder-traversal`
- [Graphs](https://github.com/akshatsinghnayal/leetcode/tree/main/0207-course-schedule): topic cluster · Representative graph traversal and shortest-path solutions. · `0207-course-schedule`
- [DP](https://github.com/akshatsinghnayal/leetcode/tree/main/0120-triangle): topic cluster · Representative dynamic-programming solutions. · `0120-triangle`

### Interview Practice

Categorized practice problems under Difficulty/.

- [Difficulty/](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Basic): practice catalog · Categorized interview-practice solution area. · `Difficulty: Basic`
- [Basic](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Basic): difficulty band · Entry-level practice problems. · `Difficulty: Basic`
- [Easy](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Easy): difficulty band · Easy practice problems across classic data structures and graph basics. · `Difficulty: Easy`
- [Medium](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Medium): difficulty band · Core interview-practice algorithms and data-structure patterns. · `Difficulty: Medium`
- [Hard](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Hard): difficulty band · Advanced practice problems. · `Difficulty: Hard`
- [Odd or Even](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Basic/Odd%20or%20Even): practice unit · Representative Basic folder with a single solution file. · `Difficulty: Basic/Odd or Even`
- [BFS Graph](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Easy/BFS%20of%20graph): practice unit · Representative Easy graph traversal folder. · `Difficulty: Easy/BFS of graph`
- [Knapsack](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Medium/0%20-%201%20Knapsack%20Problem): practice unit · Representative Medium dynamic-programming folder. · `Difficulty: Medium/0 - 1 Knapsack Problem`
- [LCS Sequences](https://github.com/akshatsinghnayal/leetcode/tree/HEAD/Difficulty%3A%20Hard/Print%20all%20LCS%20sequences): practice unit · Representative Hard folder. · `Difficulty: Hard/Print all LCS sequences`

### SQL Solutions

Standalone database-query problem solutions.

- [SQL Branch](https://github.com/akshatsinghnayal/leetcode/tree/main/0595-big-countries): query solutions · Standalone SQL-based LeetCode solutions. · `0595-big-countries`
- [Big Countries](https://github.com/akshatsinghnayal/leetcode/tree/main/0595-big-countries): sql solution · Representative SQL query solution folder. · `0595-big-countries`

## Connections

- README.md → Topic Index: indexes · Root README provides the taxonomy layer for the archive.
- README.md → LeetCode Archive: links · Root README points into the numbered problem archive.
- README.md → Difficulty/: references · Root README also covers the interview-practice catalog.
- README.md → SQL Branch: mentions · Root README includes the SQL-solution branch.
- stats.json → README.md: summarizes · Metadata is supporting repository summary information.
- Topic Index → Array/Hash: tags · Topics classify independent problems by algorithmic pattern.
- Topic Index → Pointers: tags · Problems may appear in multiple topical categories.
- Topic Index → Linked Lists: tags · List problems are cross-tagged by technique.
- Topic Index → Trees: tags · Tree problems are cross-tagged by traversal and structure.
- Topic Index → Graphs: tags · Graph problems are cross-tagged by traversal and topology.
- Topic Index → DP: tags · Dynamic-programming problems are tagged alongside their pattern.
- LeetCode Archive → Array/Hash: contains · Numbered folders are self-contained solution units.
- LeetCode Archive → Pointers: contains · Archive spans many independent algorithm implementations.
- LeetCode Archive → Linked Lists: contains · List solution folders stand alone without shared dependencies.
- LeetCode Archive → Trees: contains · Tree solution folders stand alone without shared dependencies.
- LeetCode Archive → Graphs: contains · Graph solution folders stand alone without shared dependencies.
- LeetCode Archive → DP: contains · DP solution folders stand alone without shared dependencies.
- Difficulty/ → Basic: organizes · Difficulty/ is subdivided into bands.
- Difficulty/ → Easy: organizes · Difficulty/ is subdivided into bands.
- Difficulty/ → Medium: organizes · Difficulty/ is subdivided into bands.
- Difficulty/ → Hard: organizes · Difficulty/ is subdivided into bands.
- Basic → Odd or Even: contains · Representative basic practice folder.
- Easy → BFS Graph: contains · Representative easy practice folder.
- Medium → Knapsack: contains · Representative medium practice folder.
- Hard → LCS Sequences: contains · Representative hard practice folder.
- SQL Branch → Big Countries: contains · SQL problems are separate from the C++ archive.
