{"id":44635995,"url":"https://github.com/yamcodes/leetcode-solutions-java","last_synced_at":"2026-02-14T17:30:39.911Z","repository":{"id":336918166,"uuid":"1151609152","full_name":"yamcodes/leetcode-solutions-java","owner":"yamcodes","description":"My LeetCode solutions in Java","archived":false,"fork":false,"pushed_at":"2026-02-06T22:59:16.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-07T04:19:55.745Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamcodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-06T17:18:25.000Z","updated_at":"2026-02-06T22:59:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yamcodes/leetcode-solutions-java","commit_stats":null,"previous_names":["yamcodes/leetcode-solutions-java"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/yamcodes/leetcode-solutions-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamcodes%2Fleetcode-solutions-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamcodes%2Fleetcode-solutions-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamcodes%2Fleetcode-solutions-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamcodes%2Fleetcode-solutions-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamcodes","download_url":"https://codeload.github.com/yamcodes/leetcode-solutions-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamcodes%2Fleetcode-solutions-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29450870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-14T17:30:39.472Z","updated_at":"2026-02-14T17:30:39.903Z","avatar_url":"https://github.com/yamcodes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LeetCode Solutions\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg)](#contributors)\n\nMy LeetCode solutions in Java, focused on clean code and optimal algorithms.\n\n## Solutions\n\n| #    | Problem                                                                                                               | Difficulty | Time              | Space  |\n|------|-----------------------------------------------------------------------------------------------------------------------|------------|-------------------|--------|\n| 1    | [Two Sum](https://leetcode.com/problems/two-sum/)                                                                     | Easy       | `O(n log n)`      | `O(n)` |\n| 9    | [Palindrome Number](https://leetcode.com/problems/palindrome-number/)                                                 | Easy       | `O(log10(n) / 2)` | `O(1)` |\n| 1653 | [Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced/) | Medium     | `O(n)`            | `O(1)` |\n\n## Project Structure\n\n```\nsrc/main/java/codes/yam/leetcode/{problem-slug}/\n  Solution.java              # Optimal/final solution\n  SolutionNaive.java         # Additional solutions (prefix naming: Solution*.java)\n  SolutionDp.java\n  package-info.java          # Problem metadata \u0026 solution progression\n\nsrc/test/java/codes/yam/leetcode/{problem-slug}/\n  TestCases.java             # Shared test data (static Stream\u003cArguments\u003e cases())\n  SolutionTest.java          # Tests Solution.java\n  SolutionNaiveTest.java     # One test file per solution\n  SolutionBenchmark.java     # JMH benchmarks (optional)\n```\n\nWhen a problem has multiple solution approaches, each gets its own `Solution*.java` class. `Solution.java` is always the\noptimal/final version. The progression is documented in `package-info.java`. Test data lives in a shared `TestCases.java`,\nand each solution has its own test file using `@MethodSource` to reference it.\n\n## Commands\n\n```bash\nmvn test                          # Run all tests\nmvn test -Dtest=SolutionTest      # Run a specific test class\nmvn javadoc:javadoc               # Generate Javadoc\n```\n\n## TDD Workflow (IntelliJ IDEA)\n\nHow to add a new LeetCode solution using test-driven development.\n\n### 1. Write the tests first\n\nRight-click `src/test/java/codes/yam/leetcode/` → **New → Package** → `problemslug`, then **New → Java Class** →\n`SolutionTest`.\n\nStart with LeetCode's example cases plus a few edge cases (aim for 3–5 per behavior):\n\n**For single-arg problems** — use `@ValueSource`, grouped by expected outcome:\n\n```java\nclass SolutionTest {\n    private final Solution solution = new Solution();\n\n    @ParameterizedTest(name = \"{0} is a palindrome\")\n    @ValueSource(ints = {121, 0, 1, 1221, 12321})\n    void testPalindromes(int x) {\n        assertTrue(solution.isPalindrome(x));\n    }\n\n    @ParameterizedTest(name = \"{0} is not a palindrome\")\n    @ValueSource(ints = {-121, 10, 123})\n    void testNonPalindromes(int x) {\n        assertFalse(solution.isPalindrome(x));\n    }\n}\n```\n\n**For multi-arg problems** — use `@MethodSource`:\n\n```java\nclass SolutionTest {\n    private final Solution solution = new Solution();\n\n    static Stream\u003cArguments\u003e cases() {\n        return Stream.of(\n                arguments(new int[]{2, 7, 11, 15}, 9, new int[]{0, 1}),  // basic case\n                arguments(new int[]{3, 2, 4}, 6, new int[]{1, 2}),       // not-first-pair\n                arguments(new int[]{3, 3}, 6, new int[]{0, 1}),          // duplicates\n                arguments(new int[]{-1, -2, -3, -4, -5}, -8, new int[]{2, 4})  // negatives\n        );\n    }\n\n    @ParameterizedTest\n    @MethodSource(\"cases\")\n    void twoSum(int[] nums, int target, int[] expected) {\n        assertArrayEquals(expected, solution.twoSum(nums, target));\n    }\n}\n```\n\n### 2. Generate the Solution class from the test\n\n`Solution` will be red (unresolved). Put your cursor on it and press **⌥⏎** → **Create class 'Solution'**. Change the\ntarget directory to `src/main/java` — IntelliJ creates the package automatically.\n\nThen **⌥⏎** on the red method call → **Create method** — IntelliJ infers the signature from your test args.\n\n### 3. Red → Green → Refactor\n\n1. **Red:** Run the test with **⌃⇧R** — confirm it fails\n2. **Green:** Write the minimal code to pass all cases\n3. **Refactor:** Clean up, then re-run to verify\n\n### 4. Add boilerplate\n\n- Add `package-info.java` in the main source package (Right-click → **New → File**)\n- Add Javadoc with time/space complexity to `Solution.java`\n- Ensure `Solution` is package-scoped (no `public` modifier)\n\n### 5. Verify with Maven\n\n```bash\nmvn test -Dtest=SolutionTest\n```\n\n### Useful shortcuts\n\n| Shortcut | Action                                     |\n|----------|--------------------------------------------|\n| **⌥⏎**   | Quick fix (create class/method from usage) |\n| **⌃⇧R**  | Run nearest test                           |\n| **⇧⌘T**  | Toggle between class and its test          |\n\n## Tech Stack\n\n- **Java 25** (LTS)\n- **JUnit 6** for parameterized testing\n- **JMH** for benchmarking with GC profiling\n- **Maven** for builds\n\n## Contributors\n\n\u003c!--suppress HtmlDeprecatedAttribute, HtmlUnknownAnchorTarget --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/yamcodes\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/2014360?v=4?s=100\" width=\"100px;\" alt=\"Yam Borodetsky\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYam Borodetsky\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/yamcodes/leetcode-solutions-java/commits?author=yamcodes\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/yamcodes/leetcode-solutions-java/commits?author=yamcodes\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/yamcodes/leetcode-solutions-java/commits?author=yamcodes\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#infra-yamcodes\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/HoudaBelhad\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/115419309?v=4?s=100\" width=\"100px;\" alt=\"Houda Belhad\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eHouda Belhad\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#infra-HoudaBelhad\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamcodes%2Fleetcode-solutions-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamcodes%2Fleetcode-solutions-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamcodes%2Fleetcode-solutions-java/lists"}