LeetCodeUtils 1.1.14

dotnet add package LeetCodeUtils --version 1.1.14
                    
NuGet\Install-Package LeetCodeUtils -Version 1.1.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LeetCodeUtils" Version="1.1.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LeetCodeUtils" Version="1.1.14" />
                    
Directory.Packages.props
<PackageReference Include="LeetCodeUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LeetCodeUtils --version 1.1.14
                    
#r "nuget: LeetCodeUtils, 1.1.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LeetCodeUtils@1.1.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LeetCodeUtils&version=1.1.14
                    
Install as a Cake Addin
#tool nuget:?package=LeetCodeUtils&version=1.1.14
                    
Install as a Cake Tool

LeetCodeUtils

LeetCodeUtils is a lightweight .NET 8 utility library providing canonical data structures and helper methods commonly used in LeetCode problems.
It includes:

  • ListNode (singly linked list)
  • TreeNode (binary tree)
  • ListNodeUtils (creation, conversion, printing)
  • TreeNodeUtils (creation, conversion, pretty‑printing)

Designed for interview prep, algorithm practice, and cleaner LeetCode solutions.


πŸ“¦ Install via NuGet

dotnet add package LeetCodeUtils

NuGet: https://www.nuget.org/packages/LeetCodeUtils


πŸ“‚ Solution Structure

LeetCodeUtils.sln
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ LeetCodeUtils/              # Class Library (NuGet package)
β”‚   β”‚   β”œβ”€β”€ ListNode.cs
β”‚   β”‚   β”œβ”€β”€ TreeNode.cs
β”‚   β”‚   β”œβ”€β”€ ListNodeUtils.cs
β”‚   β”‚   └── TreeNodeUtils.cs
β”‚   β”‚
β”‚   └── LeetCodeUtils.Console/      # Console demo
β”‚       └── Program.cs
β”‚
└── tests/
    └── LeetCodeUtils.Tests/        # xUnit test suite
        β”œβ”€β”€ ListNodeUtilsTests.cs
        └── TreeNodeUtilsTests.cs

πŸš€ Getting Started

Build the solution

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

Run the console demo

dotnet run --project src/LeetCodeUtils.Console

Run tests

dotnet test

πŸ”— Usage Examples

Linked List Example

using LeetCodeUtils;

// Create a linked list from an array
var head = ListNodeUtils.FromArray(new[] { 1, 2, 3, 4 });

// Convert back to array
int[] values = ListNodeUtils.ToArray(head);

// Pretty-print the list
Console.WriteLine(ListNodeUtils.ToString(head));
// Output: 1 -> 2 -> 3 -> 4

Binary Tree Example

using LeetCodeUtils;

// Create a binary tree from level-order input
var root = TreeNodeUtils.FromLevelOrder(new int?[] { 1, 2, 3, null, 5 });

// Pretty-print the tree
Console.WriteLine(TreeNodeUtils.ToPrettyString(root));

🧱 Included Data Structures

ListNode

public class ListNode {
    public int val;
    public ListNode next;
}

TreeNode

public class TreeNode {
    public int val;
    public TreeNode left;
    public TreeNode right;
}

πŸ”§ Utility Methods

ListNodeUtils

  • FromArray(int[])
  • ToArray(ListNode)
  • ToString(ListNode)
  • Append(ListNode, int)
  • Reverse(ListNode)

TreeNodeUtils

  • FromLevelOrder(int?[])
  • ToLevelOrder(TreeNode)
  • ToPrettyString(TreeNode)
  • Height(TreeNode)
  • IsBalanced(TreeNode)

πŸ§ͺ Testing

Example xUnit test:

[Fact]
public void ToString_ShouldReturnCorrectFormat()
{
    var head = ListNodeUtils.FromArray(new[] { 1, 2, 3 });
    Assert.Equal("1 -> 2 -> 3", ListNodeUtils.ToString(head));
}

Run tests:

dotnet test

πŸ“¦ NuGet Packaging

Build and pack:

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

Publish (Trusted Publishing via GitHub Actions):

dotnet nuget push ./artifacts/*.nupkg \
  --source https://api.nuget.org/v3/index.json \
  --skip-duplicate

πŸ—οΈ Roadmap

  • PrettyPrint ASCII renderer for binary trees
  • Random linked list & tree generators
  • Additional conversion helpers
  • Expanded test coverage

πŸ“œ License

MIT License Β© Wayne Eliot Blackmon

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.14 98 7/1/2026
1.0.1 419 11/18/2025