Skip to content

wblackmon/LeetCodeUtils

Repository files navigation

Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 3 column 1
---

## 📘 README.md

```markdown
# LeetCodeUtils

LeetCodeUtils is a reusable **.NET 8 class library** that provides helper utilities for solving LeetCode problems.  
It includes canonical data structures (`ListNode`, `TreeNode`) and utility methods (`ListNodeUtils`, `TreeNodeUtils`) for **creation, printing, and debugging** linked lists and binary trees.

---

📂 Solution Structure

LeetCodeUtils.sln
│
├── src/
│   ├── LeetCodeUtils/           # Class Library (NuGet-ready)
│   │   ├── ListNode.cs
│   │   ├── TreeNode.cs
│   │   ├── ListNodeUtils.cs
│   │   └── TreeNodeUtils.cs
│   │
│   └── LeetCodeUtils.Console/   # Console demo project
│       └── Program.cs
│
└── tests/
    └── LeetCodeUtils.Tests/     # xUnit test project
        ├── ListNodeUtilsTests.cs
        └── TreeNodeUtilsTests.cs

🚀 Getting Started

1. Clone & Build

git clone https://github.com/wayneblackmon/LeetCodeUtils.git
cd LeetCodeUtils
dotnet build

2. Run Console Demo

dotnet run --project src/LeetCodeUtils.Console

3. Run Tests

dotnet test

🔗 Usage Examples

Linked List

using LeetCodeUtils;

var list = ListNodeUtils.Create(new int[] { 1, 2, 3, 4 });
Console.WriteLine(list.Print()); 
// Output: 1 -> 2 -> 3 -> 4

Binary Tree

using LeetCodeUtils;

var tree = TreeNodeUtils.Create(new int[] { 1, 2, 3, 4, 5 });
Console.WriteLine(tree.Print()); 
// Output: [1, 2, 3, 4, 5]

🧪 Testing

Unit tests are included in the LeetCodeUtils.Tests project using xUnit:

[Fact]
public void Print_ShouldReturnCorrectString()
{
    var head = ListNodeUtils.Create(new int[] { 1, 2, 3 });
    Assert.Equal("1 -> 2 -> 3", head.Print());
}

Run tests:

dotnet test

📦 NuGet Packaging

To build and pack the library:

dotnet pack src/LeetCodeUtils/LeetCodeUtils.csproj -c Release -o ./artifacts

To publish to NuGet.org:

dotnet nuget push ./artifacts/LeetCodeUtils.*.nupkg --api-key YOUR_KEY --source https://api.nuget.org/v3/index.json

🏗️ Roadmap

  • Add PrettyPrint ASCII renderer for binary trees
  • Add random generators for linked lists and trees
  • Add conversion utilities (array ↔ list/tree)
  • Expand test coverage

🚀 Automated Releases & Versioning

LeetCodeUtils uses a fully automated release pipeline powered by:

  • Semantic version tags (v1.2.3)
  • GitHub Actions CI/CD
  • NuGet Trusted Publishing (no API keys required)
  • A local versioning script (tag-release.ps1)

Publishing a new version requires one command.


🔢 Versioning & Tagging

Use the tag-release.ps1 script to create and push version tags.

Automatic Patch Bump

./tag-release.ps1 -Patch


## 📜 License

MIT License © Wayne Eliot Blackmon

⚡ This is now a single, self‑contained README file you can drop into the root of your repo. It covers solution structure, usage, tests, NuGet packaging, and roadmap all in one place.

👉 Do you want me to also add badges (build status, NuGet version, test coverage) so your README looks polished when hosted on GitHub?

About

LeetCodeUtils is a lightweight .NET 8 library providing canonical data structures and helper utilities for solving algorithm problems. Includes ListNode and TreeNode with creation and printing methods, plus console demos and xUnit tests. Ideal for LeetCode practice and interview prep.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors