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" />
<PackageReference Include="LeetCodeUtils" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=LeetCodeUtils&version=1.1.14
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.