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, C++ and C#, 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
|- .vscode
|- tasks.json
|- Problems
|- Arrays
|- Matrix
|- Rotate-Image
|- Rotate-Image.c
|- Rotate-Image.cpp
|- Rotate-Image.cs
|- Rotate-Image.csproj
|- README.md
|- Set-Matrix-Zeroes
|- Spiral-Matrix
|- Word-Search
|- Strings
|- Intervals
|- Binary Search
|- Dynamic Programming
|- Linked Lists
|- Trees
|- Heaps
|- Graphs
|- Sources
|- Sheldon.gif
-
.vscode: Contains the 'tasks.json' file that configures the build task in Visual Studio Code for
/usr/bin/g++
and the configuration for the output generated${fileDirname}\\${fileBasenameNoExtension}.out
-
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-Sum
folder contains the C source codeTwo-Sum.c
(Only in the first problem of each topic there is an implementation in C language to go a little deeper), the C++ source codeTwo-Sum .cpp
, the C# source code inTwo-Sum.cs
and the .NET project settings inTwo-Sum.csproj
and finally theREADME.md
file -
Sources: Contains the images and gifs used in the repository, such as Sheldon Cooper's 😁 gif
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 also written in C++, only the first problem of each topic includes the solution in C and only in the last problem of each topic includes the solution in F#, so to use this repository you must have installed:
To compile C# and F# you need to install dotnet-sdk
- dotnet-sdk-8.0
At this time the dotnet sdk is available from the Ubuntu 22.04 and Fedora 39 source, so, to install you can copy and paste the following commands:
Ubuntu 22.04 or later:
sudo apt update && \
sudo apt install -y dotnet-sdk-8.0
Fedora 39 or later:
sudo dnf install dotnet-sdk-8.0
Note: To install on other linux versions or linux distributions, please check this page.
If you want use this repository with C and C++ then you should install gcc
and g++
- gcc
- g++
To install them on Debian based distributions you can type:
Debian based distributions:
sudo apt update && \
sudo apt install build-essential -y
Red hat based distributions:
sudo dnf install gcc g++ -y
# | Title | Solution | Difficulty |
---|---|---|---|
0001 | Two Sum | C - C++ - C# | Easy |
0011 | Container With Most Water | C++ - C# | Medium |
0015 | 3Sum | C++ - C# | Medium |
0033 | Search in Rotated Sorted Array | C++ - C# | Medium |
0053 | Maximum Subarray | C++ - C# | Medium |
0121 | Best Time to Buy and Sell Stock | C++ - C# | Medium |
0152 | Maximum Product Subarray | C++ - C# | Medium |
0153 | Find Minimum in Rotated Sorted Array | C++ - C# | Medium |
0217 | Contains Duplicate | C++ - C# | Easy |
0238 | Product of Array Except Self | C++ - C# - F# | Easy |
# | Title | Solution | Difficulty |
---|---|---|---|
0048 | Rotate Image | C - C++ - C# | Medium |
0054 | Spiral Matrix | C++ - C# | Medium |
0073 | Set Matrix Zeroes | C++ - C# | Medium |
0079 | Word Search | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0003 | Longest Substring Without Repeating Characters | C - C++ - C# | Medium |
0005 | Longest Palindromic Substring | C++ - C# | Medium |
0020 | Valid Parentheses | C++ - C# | Easy |
0049 | Group Anagrams | C++ - C# | Medium |
0076 | Minimum Window Substring | C++ - C# | Hard |
0125 | Valid Palindrome | C++ - C# | Easy |
0242 | Valid Anagram | C++ - C# | Easy |
0271 | Encode and Decode Strings | C++ - C# | Medium |
0424 | Longest Repeating Character Replacement | C++ - C# | Medium |
0647 | Palindromic Substrings | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0056 | Merge Intervals | C - C++ - C# | Medium |
0057 | Insert Interval | C++ - C# | Medium |
0252 | Meeting Rooms | C++ - C# | Easy |
0253 | Meeting Rooms II | C++ - C# | Medium |
0435 | Non-overlapping Intervals | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0190 | Reverse Bits | C - C++ - C# | Easy |
0191 | Number of 1 Bits | C++ - C# | Easy |
0268 | Missing Number | C++ - C# | Easy |
0338 | Counting Bits | C++ - C# | Easy |
0371 | Sum of Two Integers | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0055 | Jump Game | C - C++ - C# | Medium |
0062 | Unique Paths | C++ - C# | Medium |
0070 | Climbing Stairs | C++ - C# | Easy |
0091 | Decode Ways | C++ - C# | Medium |
0139 | Word Break | C++ - C# | Medium |
0198 | House Robber | C++ - C# | Medium |
0213 | House Robber II | C++ - C# | Medium |
0300 | Longest Increasing Subsequence | C++ - C# | Medium |
0322 | Coin Change | C++ - C# | Medium |
0377 | Combination Sum IV | C++ - C# | Medium |
1143 | Longest Common Subsequence | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0019 | Remove Nth Node From End of List | C - C++ - C# | Medium |
0021 | Merge Two Sorted Lists | C++ - C# | Easy |
0023 | Merge k Sorted Lists | C++ - C# | Hard |
0141 | Linked List Cycle | C++ - C# | Easy |
0143 | Reorder List | C++ - C# | Medium |
0206 | Reverse Linked List | C++ - C# - F# | Easy |
# | Title | Solution | Difficulty |
---|---|---|---|
0098 | Validate Binary Search Tree | C - C++ - C# | Medium |
0100 | Same Tree | C++ - C# | Easy |
0102 | Binary Tree Level Order Traversal | C++ - C# | Medium |
0104 | Maximum Depth of Binary Tree | C++ - C# | Easy |
0105 | Construct Binary Tree from Preorder and Inorder Traversal | C++ - C# | Medium |
0124 | Binary Tree Maximum Path Sum | C++ - C# | Hard |
0208 | Implement Trie (Prefix Tree) | C++ - C# | Medium |
0211 | Design Add and Search Words Data Structure | C++ - C# | Medium |
0212 | Word Search II | C++ - C# | Hard |
0226 | Invert Binary Tree | C++ - C# | Hard |
0230 | Kth Smallest Element in a BST | C++ - C# | Medium |
0235 | Lowest Common Ancestor of a Binary Search Tree | C++ - C# | Medium |
0297 | Serialize and Deserialize Binary Tree | C++ - C# | Hard |
0572 | Subtree of Another Tree | C++ - C# - F# | Easy |
# | Title | Solution | Difficulty |
---|---|---|---|
0295 | Find Mediumn from Data Stream | C - C++ - C# | Hard |
0347 | Top K Frequent Elements | C++ - C# | Medium |
0355 | Design Twitter | C++ - C# - F# | Medium |
# | Title | Solution | Difficulty |
---|---|---|---|
0128 | Longest Consecutive Sequence | C - C++ - C# | Medium |
0133 | Clone Graph | C++ - C# | Medium |
0200 | Number of Islands | C++ - C# | Medium |
0207 | Course Schedule | C++ - C# | Medium |
0261 | Graph Valid Tree | C++ - C# | Medium |
0269 | Alien Dictionary | C++ - C# | Hard |
0323 | Number of Connected Components in an Undirected Graph | C++ - C# | Medium |
0417 | Pacific Atlantic Water Flow | C++ - C# - F# | Medium |
- 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
- Pontus Nyman: C++ in Space
- Bjarne Stroustrup - The Essence of C++
- CppCon 2015: Kate Gregory “Stop Teaching C"
- Bjarne Stroustrup: C++ | Lex Fridman Podcast #48
- Bjarne Stroustrup: Why you should avoid Linked Lists
- Keynote: C++'s Superpower - Matt Godbolt - CPPP 2021
- CppCon 2016: Jason Turner “Practical Performance Practices"
- Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022
- C++ in Constrained Environments - Bjarne Stroustrup - CppCon 2022
- Keynote: "Am I A Good Programmer?" - Kate Gregory - CppNorth 2022
- CppCon 2017: Bjarne Stroustrup “Learning and Teaching Modern C++”
- CppCon 2017: Peter Goldsborough “A Tour of Deep Learning With C++”
- CppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”
- CppCon 2018: Peter Goldsborough “Machine Learning in C++ with PyTorch”
- CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"
- CppCon 2016: Bjarne Stroustrup "The Evolution of C++ Past, Present and Future"
- The Most Important Optimizations to Apply in Your C++ Programs - Jan Bielak - CppCon 2022
- Trading at light speed: designing low latency systems in C++ - David Gross - Meeting C++ 2022
- CppCon 2018: Gordon Brown “A Modern C++ Programming Model for GPUs using Khronos SYCL”
- The Imperatives Must Go! [Functional Programming in Modern C++] - Victor Ciura - CppCon 2022
- Bjarne Stroustrup's Closing Keynote at Code Europe 2022 in Cracow – "How to evolve a language"
- Writing Safety Critical Automotive Software for High Perf AI Hardware - Michael Wong - CppCon 2019
Cppreference.com. (s. f.). https://en.cppreference.com/w/
Eckel, B. (2004). Thinking in C++. Thinking in C++ (2nd ed.). Pearson.
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.
Written with ❤️ by Jonas Lara for anyone who is interested