This file provides guidance to AI coding agents such as Claude Code (claude.ai/code) and Gemini Code Assist when working with code in this repository.
When working with this codebase, always follow modern .NET and C# best practices:
- Use latest C# language features (records, pattern matching, nullable reference types, file-scoped namespaces)
- Follow .NET naming conventions and coding standards
- Leverage modern async/await patterns where applicable
- Use
System.Text.Jsonfor JSON serialization - Prefer
Span<T>andMemory<T>for performance-critical code - Use collection expressions and LINQ for data manipulation
- Apply proper error handling with exceptions and Result patterns
- Write clean, readable code with meaningful variable names and comprehensible tests
- Use nullable reference types and enable all relevant compiler warnings
dotnet builddotnet test --no-restoredotnet test --filter "FullyQualifiedName~TwoSumTest"cd ./LeetCode
dotnet run
# Run specific commands
dotnet run benchmark LRUCache --csharp
dotnet run info MergeTwoLists
dotnet run listThis is a LeetCode problem solutions repository with benchmarking capabilities, structured as follows:
- LeetCode.CSharp - C# implementations of LeetCode problems with xUnit tests and BenchmarkDotNet benchmarks
- LeetCode.FSharp - F# implementations of selected problems
- LeetCode - Console application for running benchmarks and viewing problem information
Problem Organization:
All C# problems are implemented as static methods in the Problem partial class, decorated with [LeetCode]
attributes containing metadata (description, difficulty, category, NeetCode video link). Each problem includes inline
xUnit tests using [Fact] attributes.
Benchmark Structure:
Each problem has a corresponding benchmark class in the Benchmarks folder that inherits from a base Benchmark class.
Benchmarks use BenchmarkDotNet with GlobalSetup/GlobalCleanup for test data preparation.
Console Application:
Built with Spectre.Console, provides an interactive menu system and CLI commands (app, benchmark, info, list, workflow) for running benchmarks and viewing problem information.
Testing:
Uses xUnit with Shouldly for test assertions. Tests are co-located with problem implementations for easy access.
Package Management:
Uses Directory.Packages.props for centralized NuGet package version management across all projects.