Skip to content

Test-Driven C# environment for solving leetcode problems. These problems are from the neetcode 150 roadmap.

Notifications You must be signed in to change notification settings

HansonSoftware/cs-neetcode

Repository files navigation

Test Driven C# Environment for Solving Leetcode Locally

How to use this repo:

  • Use branch clean for starting fresh and using the included script to create your own problems.

  • Use branch base (not included yet) to start solving the problems provided

    • Run dotnet test from the root directory to test the whole project
    • Run cd {PROBLEM_NAME} && dotnet test to test a problem individually
    • Write your solutions in {PROBLEM_NAME}/{PROBLEM_NAME}.cs
    • Add more tests in {PROBLEM_NAME}.Tests/{PROBLEM_NAME}Tests.cs
  • The main branch includes all of my solutions.

Note: I created a blogpost about how I made this repo and give instructions on how you can create one too.

LC Problems with Tests in this repository (work in progress):

Arrays & Hashing:

  1. Two Sum LC #1
  2. Valid Anagram LC #242
  3. Encode and Decode Strings LC #271

Two Pointers:

  1. Valid Palindrome LC #125

Stack:

  1. Valid Parentheses LC #20

Binary Search:

  1. Binary Search LC #704
  2. Search a 2D Matrix LC #74

Sliding Window

  1. Best Time to Buy & Sell Stock LC #121

Linked List:

  1. LRU Cache LC #146

Tree:

  1. Invert Binary Tree LC #226
  2. Serialize & Deserialize Binary Tree LC #297

Heap / Priority Queue:

  1. Task Scheduler LC #621
  2. Kth Largest Element in a Stream LC #703

Greedy:

  1. Maximum Subarray LC #53

Graph:

  1. Course Schedule LC #207

Dynamic Programming:

  1. Climbing Stairs LC #70
  2. LCS (Longest Common Subsequence) LC #1143

Bit Manipulation:

  1. Single Number LC #136
  2. Missing Number LC #268
  3. Sum of Two Integers (no + or - operator) LC #371

File Structure:

cs-neetcode/
│
├── TwoSum/
│   ├── TwoSum.cs
│   └── TwoSumTests.cs
│
├── ValidAnagram/
│   ├── ValidAnagram.cs
│   └── ValidAnagramTests.cs
│
├── Etc.../
│
├── cs-neetcode.sln
└── .gitignore

Included Script:

Be sure to make add_problem.sh executable:

chmod +x add_problem.sh

Run it with ./add_problem.sh

Input your leetcode problems name.

Testing:

You can test the entire repository by running the following command from the root directory of the project.

dotnet test -v q

This will run the tests with minimal terminal output.

To test an individual leetcode solution, run the same command from the corresponding directory.

For example:

TwoSum.Tests/

cd TwoSum.Tests

dotnet test

dotnet test

About

Test-Driven C# environment for solving leetcode problems. These problems are from the neetcode 150 roadmap.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published