According to Sheldon Cooper the best number is 73, because 73 is the 21st prime number. Its mirror, 37, is the 12th prime number. 21 is the product of multiplying 7 by 3 and in binary, 73 is a palindrome: 1001001
Sheldon Cooper (character in the famous series "The Big-Bang Theory")
This is a repository that will take you by the hand in the 73 most useful LeetCode problems, well they are actually 76, 😬 the algorithms are written in C# and F#, I wrote each program in the most optimal way and included the main function or method of the program to test on your machine, a README file with solution notes and for problems 252, 253, 269, 271 and 323 being Premium subscription problems, I included a README with the description of each problem.
No hurry, but no rest
The repository is divided into 4 folders:
|- Repository
|- Problems
|- Arrays
|- Matrix
|- Rotate-Image
|- Set-Matrix-Zeroes
|- Spiral-Matrix
|- Word-Search
|- Word-Search.cs
|- Word-Search.csproj
|- Word-Search.fsx
|- README.md
|- Strings
|- Intervals
|- Binary Search
|- Dynamic Programming
|- Linked Lists
|- Trees
|- Heaps
|- Graphs
|- Sources
|- Sheldon.gif
-
Problems: Contains the folders for each topic, inside it has a folder per problem and inside each folder is the source code and the README that explains the problem, for example the
Two-Sumfolder contains the C# source code inTwo-Sum.csand the .NET project settings inTwo-Sum.csproj(only the last problem of each topic also includes an F# solution, e.g.Word-Search.fsx) and finally theREADME.mdfile. Every problem'sREADME.mdalso ends with a Suggested practice section linking 3 related LeetCode problems, so you can practice the same pattern -
Sources: Contains the images and gifs used in the repository, such as Sheldon Cooper's gif
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0001 | Two Sum | C# | Easy |
| 0011 | Container With Most Water | C# | Medium |
| 0015 | 3Sum | C# | Medium |
| 0033 | Search in Rotated Sorted Array | C# | Medium |
| 0053 | Maximum Subarray | C# | Medium |
| 0121 | Best Time to Buy and Sell Stock | C# | Medium |
| 0152 | Maximum Product Subarray | C# | Medium |
| 0153 | Find Minimum in Rotated Sorted Array | C# | Medium |
| 0217 | Contains Duplicate | C# | Easy |
| 0238 | Product of Array Except Self | C# - F# | Easy |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0048 | Rotate Image | C# | Medium |
| 0054 | Spiral Matrix | C# | Medium |
| 0073 | Set Matrix Zeroes | C# | Medium |
| 0079 | Word Search | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0003 | Longest Substring Without Repeating Characters | C# | Medium |
| 0005 | Longest Palindromic Substring | C# | Medium |
| 0020 | Valid Parentheses | C# | Easy |
| 0049 | Group Anagrams | C# | Medium |
| 0076 | Minimum Window Substring | C# | Hard |
| 0125 | Valid Palindrome | C# | Easy |
| 0242 | Valid Anagram | C# | Easy |
| 0271 | Encode and Decode Strings | C# | Medium |
| 0424 | Longest Repeating Character Replacement | C# | Medium |
| 0647 | Palindromic Substrings | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0056 | Merge Intervals | C# | Medium |
| 0057 | Insert Interval | C# | Medium |
| 0252 | Meeting Rooms | C# | Easy |
| 0253 | Meeting Rooms II | C# | Medium |
| 0435 | Non-overlapping Intervals | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0190 | Reverse Bits | C# | Easy |
| 0191 | Number of 1 Bits | C# | Easy |
| 0268 | Missing Number | C# | Easy |
| 0338 | Counting Bits | C# | Easy |
| 0371 | Sum of Two Integers | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0055 | Jump Game | C# | Medium |
| 0062 | Unique Paths | C# | Medium |
| 0070 | Climbing Stairs | C# | Easy |
| 0091 | Decode Ways | C# | Medium |
| 0139 | Word Break | C# | Medium |
| 0198 | House Robber | C# | Medium |
| 0213 | House Robber II | C# | Medium |
| 0300 | Longest Increasing Subsequence | C# | Medium |
| 0322 | Coin Change | C# | Medium |
| 0377 | Combination Sum IV | C# | Medium |
| 1143 | Longest Common Subsequence | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0019 | Remove Nth Node From End of List | C# | Medium |
| 0021 | Merge Two Sorted Lists | C# | Easy |
| 0023 | Merge k Sorted Lists | C# | Hard |
| 0141 | Linked List Cycle | C# | Easy |
| 0143 | Reorder List | C# | Medium |
| 0206 | Reverse Linked List | C# - F# | Easy |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0098 | Validate Binary Search Tree | C# | Medium |
| 0100 | Same Tree | C# | Easy |
| 0102 | Binary Tree Level Order Traversal | C# | Medium |
| 0104 | Maximum Depth of Binary Tree | C# | Easy |
| 0105 | Construct Binary Tree from Preorder and Inorder Traversal | C# | Medium |
| 0124 | Binary Tree Maximum Path Sum | C# | Hard |
| 0208 | Implement Trie (Prefix Tree) | C# | Medium |
| 0211 | Design Add and Search Words Data Structure | C# | Medium |
| 0212 | Word Search II | C# | Hard |
| 0226 | Invert Binary Tree | C# | Hard |
| 0230 | Kth Smallest Element in a BST | C# | Medium |
| 0235 | Lowest Common Ancestor of a Binary Search Tree | C# | Medium |
| 0297 | Serialize and Deserialize Binary Tree | C# | Hard |
| 0572 | Subtree of Another Tree | C# - F# | Easy |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0295 | Find Mediumn from Data Stream | C# | Hard |
| 0347 | Top K Frequent Elements | C# | Medium |
| 0355 | Design Twitter | C# - F# | Medium |
| # | Title | Solution | Difficulty |
|---|---|---|---|
| 0128 | Longest Consecutive Sequence | C# | Medium |
| 0133 | Clone Graph | C# | Medium |
| 0200 | Number of Islands | C# | Medium |
| 0207 | Course Schedule | C# | Medium |
| 0261 | Graph Valid Tree | C# | Medium |
| 0269 | Alien Dictionary | C# | Hard |
| 0323 | Number of Connected Components in an Undirected Graph | C# | Medium |
| 0417 | Pacific Atlantic Water Flow | C# - F# | Medium |
The focus of this repository is towards C#, so you can use it from Windows, Linux, Mac, Docker or even GitHub Codespaces, but it is intended to be used on Linux, specifically an Ubuntu based distribution or Red Hat based distribution, no matter if it is a complete distro or a WSL distro. All solutions are written in C#, and only the last problem of each topic also includes a solution in F#.
- dotnet-sdk-10.0 — required to build and run both the C# and F# solutions.
Ubuntu 22.04 or later:
sudo apt update && \
sudo apt install -y dotnet-sdk-10.0Fedora 39 or later:
sudo dnf install -y dotnet-sdk-10.0Note: To install on other Linux versions or distributions, Windows or macOS, please check this page.
Docker: run everything inside the official SDK image, mounting the repository as a volume:
docker run --rm -it -v "${PWD}:/repo" -w /repo mcr.microsoft.com/dotnet/sdk:10.0 bashGitHub Codespaces: open the repository in a Codespace, the container image ships with dotnet-sdk-10.0 already installed, so you can build and test right away with no extra setup.
- Clone the repository:
git clone https://github.com/jonas1ara/73.git cd 73 - Restore dependencies:
dotnet restore 73.sln
- Verify your SDK version:
dotnet --version
If you are on Windows and use this repository with Visual Studio, you just have to change the solution to compile: open 73.sln, pick the desired project in the Solution Explorer and set it as the startup project (or select it from the run configuration dropdown) to build and run it.
Every problem has a matching <Problem>.Tests xUnit project, all registered in 73.sln, and they also run automatically on every push/PR to main via the Tests GitHub Actions workflow.
dotnet test 73.slndotnet test Problems/<Topic>/<Problem>.Tests/<Problem>.Tests.csprojFor example:
dotnet test Problems/Graphs/Course-Schedule.Tests/Course-Schedule.Tests.csprojdotnet test 73.sln --filter "FullyQualifiedName~CanFinish_DetectsWhetherAllCoursesCanBeCompleted"dotnet test 73.sln --collect:"XPlat Code Coverage"- Open
73.sln. - Go to
Test→Test Explorer(or pressCtrl+E, T). - Click Run All Tests to run the whole solution, or right-click a specific test/project in Test Explorer and choose Run to run just that one.
- High Speed History of C#
- Mono Edge - Miguel de Icaza
- .NET at Stack Overflow | .NET Conf 2022
- Miguel de Icaza's Vision Keynote - UnoConf 2019
- Full stack web UI with Blazor in .NET 8 | .NET Conf 2023
- Patterns for high-performance C# - Federico Andres Lois
- Let's design a new C# language feature! | .NET Conf 2022
- Adam SITNIK: Solving .NET performance issues | UCP2019
- What’s Next in C#? - Mads Torgersen - Copenhagen DevFest 2023
- S101 - Keynote with Scott Hunter, Mads Torgersen, and Miguel De Icaza
- The functional journey of C# - Mads Torgersen - NDC Copenhagen 2022
- Stop using Entity Framework as a DTO provider! - Chris Klug - NDC Oslo 2023
- You are doing logging in .NET wrong. Let’s fix it. - Nick Chapsas - NDC Oslo 2023
- .NET Systems Programming Learned the Hard Way - Aaron Stannard - NDC Oslo 2023
- Keynote: The Microsoft Open Source Cinematic Universe - Phase 2 - Scott Hanselman
- Using C# Source Generators to Build a .NET IoT Device - Alon Fliess - NDC Melbourne 2022
- Patterns for application development with ASP.NET Core - Damian Edwards & David Fowler
- Performance tricks I learned from contributing to open source .NET packages - Daniel Marbach
- Real-world examples on optimizing .NET performance - Stefán Jökull Sigurðarson - NDC Oslo 2023
F# Docs - Get started, Tutorials, reference. https://fsharp.org/docs/
C# Docs - Get started, Tutorials, reference. https://learn.microsoft.com/en-us/dotnet/csharp/
Cormen, T. H., Leiserson, C. E., Rivest, R. L. & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press.
This project is licensed under the MIT License.
Written with ❤️ since December 2022 by Jonas Lara for anyone who is interested — started in a time without AI, improved in the age of AI.
