# leetcode **Repository Path**: elord/leetcode ## Basic Information - **Project Name**: leetcode - **Description**: leetcode同步代码 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-28 - **Last Updated**: 2026-11-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LeetCode Java Solutions This is a repository of LeetCode algorithm solutions implemented in Java. The solutions are organized by difficulty level (Easy, Medium, Hard), and include detailed problem-solving approaches and test cases. ## Project Features - **Clear Structure**: Solutions are categorized into three difficulty levels, each with its own solution class. - **Comprehensive Testing**: Full unit tests provided, covering major functionalities. - **Tool Support**: Includes commonly used data structure utility classes (e.g., ListNode for linked lists). - **Detailed Comments**: Core methods are thoroughly documented with Chinese comments. ## Project Structure ``` src/main/java/org/example/ ├── ListNode.java # Linked list node utility class ├── Utils.java # General utility methods ├── hard/ │ └── OtherSolution.java # Hard-level other algorithms └── mid/ ├── HardSolution.java # Hard-level algorithms (under Medium category) ├── MidSolution.java # Medium-difficulty algorithms └── SimpleSolution.java # Easy-difficulty algorithms ``` ## Main Features ### Easy Solutions (SimpleSolution) - Calculate length of the last word - Add one to an array - Add binary strings - Compute square root - Remove duplicates from a linked list ### Medium Solutions (MidSolution) - Combination Sum series problems - String multiplication - Permutations and permutation with duplicates - Matrix rotation - Group anagrams - Spiral matrix traversal - Jump game - Merge intervals - Matrix generation - Rotate linked list - Path counting - Simplify path - Edit distance - Set matrix zeros - Search in 2D matrix - Sort colors - Combination problems - Generate subsets - Word search ### Hard Solutions (HardSolution/OtherSolution) - First missing positive number - Trapping rain water - N-Queens problem - Permutation sequence - Number validation - Text justification - Minimum window substring - Maximum rectangle area ## Dependency Configuration The project uses Maven for building and management. Required environment: - JDK 8 or higher - Maven 3.x Main dependencies: - JUnit 4.13.2 (testing framework) ## Quick Start 1. Clone the project: ```bash git clone https://gitee.com/elord/leetcode.git ``` 2. Compile with Maven: ```bash mvn clean compile ``` 3. Run tests: ```bash mvn test ``` ## Sample Code **Remove duplicates from a linked list:** ```java ListNode head = new ListNode(1, new ListNode(1, new ListNode(2))); ListNode result = new SimpleSolution().deleteDuplicates(head); // Output: 1 -> 2 ``` **Calculate combination sum:** ```java int[] candidates = {2, 3, 6, 7}; List> result = new MidSolution().combinationSum(candidates, 7); // Returns all combinations that sum to 7 ``` ## Test Coverage The project includes comprehensive unit tests written using the JUnit framework: - `HardSolutionTest` - Tests for hard-level algorithms - `MidSolutionTest` - Tests for medium-level algorithms - `SimpleSolutionTest` - Tests for easy-level algorithms Run tests: ```bash mvn test -Dtest=*Test ``` ## Utility Classes ### ListNode Linked list node class for handling linked list problems: ```java ListNode node = new ListNode(1); ListNode nodeWithNext = new ListNode(1, nextNode); ``` ### Utils Provides common helper methods: - `generateListNodes(int... vals)` - Generate a linked list from input values - `printTwoDimensionArray(int[][] arr)` - Print a 2D array ## License This project is intended solely for learning and communication purposes. ## Contribution Guidelines Pull requests and issues are welcome to improve code quality. When submitting code, please ensure: - Follow existing code style - Add necessary comments - Provide corresponding test cases