Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnodivad/leetcode
✅ Solutions to LeetCode by Java
https://github.com/gnodivad/leetcode
leetcode leetcode-java leetcode-solutions leetcode-sql
Last synced: 10 days ago
JSON representation
✅ Solutions to LeetCode by Java
- Host: GitHub
- URL: https://github.com/gnodivad/leetcode
- Owner: gnodivad
- Created: 2021-03-01T07:29:42.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T03:38:20.000Z (over 3 years ago)
- Last Synced: 2024-11-20T00:31:06.508Z (2 months ago)
- Topics: leetcode, leetcode-java, leetcode-solutions, leetcode-sql
- Homepage: https://leetcode.com/
- Size: 192 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LeetCode
## Problems
| # | Difficulty | Title | Solutions | Tag |
|:----:|:----------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------:|
| 1 | Easy | [Two Sum](https://leetcode.com/problems/two-sum) | [](solutions/0001-two-sum.md) | Array, Hash Table |
| 15 | Medium | [3 Sum](https://leetcode.com/problems/3sum) | [](solutions/0015-3sum.md) | Array, Two Pointers |
| 19 | Medium | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list) | [](solutions/0019-remove-nth-node-from-end-of-list.md) | Linked List |
| 21 | Easy | [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists) | [](solutions/0021-merge-two-sorted-lists.md) | Linked List |
| 26 | Easy | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array) | [](solutions/0026-remove-duplicates-from-sorted-array.md) | Array |
| 33 | Medium | [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array) | [](solutions/0033-search-in-rotated-sorted-array.md) | Array, Binary Search |
| 34 | Medium | [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array) | [](solutions/0034-find-first-and-last-position-of-element-in-sorted-array.md) | Array, Binary Search |
| 39 | Medium | [Combination Sum](https://leetcode.com/problems/combination-sum) | [](solutions/0039-combination-sum.md) | Backtracking |
| 46 | Easy | [Permutations](https://leetcode.com/problems/permutations) | [](solutions/0046-permutations.md) | Backtracking |
| 51 | Hard | [N-Queens](https://leetcode.com/problems/n-queens) | [](solutions/0051-n-queens.md) | Backtracking |
| 53 | Medium | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray) | [](solutions/0053-maximum-subarray.md) | Array, Dynamic Programming, Kadane Algorithm, Divide and Conquer |
| 54 | Medium | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix) | [](solutions/0054-spiral-matrix.md) | Array |
| 56 | Medium | [Merge Intervals](https://leetcode.com/problems/merge-intervals) | [](solutions/0056-merge-intervals.md) | Array, Graph, Connected Component |
| 62 | Medium | [Unique Paths](https://leetcode.com/problems/unique-paths) | [](solutions/0062-unique-paths.md) | Dynamic Programming |
| 66 | Easy | [Plus One](https://leetcode.com/problems/plus-one) | [](solutions/0066-plus-one.md) | Array |
| 69 | Easy | [Sqrt(x)](https://leetcode.com/problems/sqrtx) | [](solutions/0069-sqrtx.md) | Binary Search |
| 70 | Easy | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs) | [](solutions/0070-climbing-stairs.md) | Dynamic Programming |
| 72 | Hard | [Edit Distance](https://leetcode.com/problems/edit-distance) | [](solutions/0070-edit-distance.md) | Dynamic Programming |
| 75 | Hard | [Sort Colors](https://leetcode.com/problems/sort-colors) | [](solutions/0075-sort-colors.md) | Dynamic Programming |
| 83 | Easy | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list) | [](solutions/0083-remove-duplicates-from-sorted-list.md) | Linked List |
| 94 | Medium | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal) | [](solutions/0094-binary-tree-inorder-traversal.md) | Binary Tree, Morris Traversal |
| 98 | Medium | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree) | [](solutions/0098-validate-binary-search-tree.md) | Linked List |
| 101 | Easy | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree) | [](solutions/0101-symmetric-tree.md) | BFS |
| 102 | Medium | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal) | [](solutions/0102-binary-tree-level-order-traversal.md) | BFS |
| 104 | Easy | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree) | [](solutions/0104-maximum-depth-of-binary-tree.md) | BST |
| 108 | Easy | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree) | [](solutions/0108-convert-sorted-array-to-binary-search-tree.md) | BST |
| 110 | Easy | [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree) | [](solutions/0110-balanced-binary-tree.md) | BST |
| 112 | Easy | [Path Sum](https://leetcode.com/problems/path-sum) | [](solutions/0112-path-sum.md) | Binary Tree |
| 121 | Easy | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock) | [](solutions/0121-best-time-to-buy-and-sell-stock.md) | Dynamic Programming |
| 122 | Easy | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii) | [](solutions/0122-best-time-to-buy-and-sell-stock-ii.md) | Array |
| 125 | Easy | [Valid Palindrome](https://leetcode.com/problems/valid-palindrome) | [](solutions/0125-valid-palindrome.md) | String, Two Pointers |
| 130 | Medium | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions) | [](solutions/0130-surrounded-regions.md) | DFS |
| 134 | Medium | [Gas Station](https://leetcode.com/problems/gas-station) | [](solutions/0134-gas-station.md) | Array |
| 141 | Easy | [Linked List Cycle](https://leetcode.com/problems/linked-list-cycle) | [](solutions/0141-linked-list-cycle.md) | Linked List, Floyd's Cycle Finding Algorithm |
| 144 | Medium | [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal) | [](solutions/0144-binary-tree-preorder-traversal.md) | Binary Tree, Morris Traversal |
| 145 | Medium | [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal) | [](solutions/0145-binary-tree-postorder-traversal.md) | Binary Tree |
| 146 | Medium | [LRU Cache](https://leetcode.com/problems/lru-cache) | [](solutions/0146-lru-cache.md) | LinkedHashMap |
| 150 | Medium | [Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation) | [](solutions/0150-evaluate-reverse-polish-notation.md) | Stack |
| 151 | Medium | [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string) | [](solutions/0151-reverse-words-in-a-string.md) | String |
| 160 | Easy | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists) | [](solutions/0160-intersection-of-two-linked-lists.md) | Linked List |
| 162 | Medium | [Find Peak Element](https://leetcode.com/problems/find-peak-element) | [](solutions/0162-find-peak-element.md) | Array |
| 167 | Easy | [Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted) | [](solutions/0167-two-sum-ii-input-array-is-sorted.md) | Array, Two Pointers |
| 198 | Medium | [House Robber](https://leetcode.com/problems/house-robber) | [](solutions/0198-house-robber.md) | Dynamic Programming |
| 200 | Medium | [Number of Islands](https://leetcode.com/problems/number-of-islands) | [](solutions/0200-number-of-islands.md) | 2D Array, DFS |
| 206 | Easy | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list) | [](solutions/0206-reverse-linked-list.md) | Linked List |
| 207 | Medium | [Course Schedule](https://leetcode.com/problems/course-schedule) | [](solutions/0207-course-schedule.md) | Topological Sort |
| 210 | Medium | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii) | [](solutions/0207-course-schedule-ii.md) | Topological Sort |
| 215 | Medium | [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array) | [](solutions/0215-kth-largest-element-in-an-array.md) | Heap, Quickselect |
| 226 | Easy | [Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree) | [](solutions/0226-invert-binary-tree.md) | Array |
| 230 | Medium | [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst) | [](solutions/0230-kth-smallest-element-in-a-bst.md) | Array |
| 234 | Easy | [Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list) | [](solutions/0234-palindrome-linked-list.md) | Linked List |
| 235 | Medium | [Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree) | [](solutions/0235-lowest-common-ancestor-of-a-binary-search-tree.md) | Binary Search Tree |
| 237 | Easy | [Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list) | [](solutions/0237-delete-node-in-a-linked-list.md) | BST |
| 238 | Medium | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self) | [](solutions/0238-product-of-array-except-self.md) | Array |
| 266 | Easy | [Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation) | [](solutions/0266-palindrome-permutation.md) | String |
| 270 | Easy | [Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value) | [](solutions/0270-closest-binary-search-tree-value.md) | BST, Binary Search |
| 283 | Easy | [Move Zeroes](https://leetcode.com/problems/move-zeroes) | [](solutions/0283-move-zeroes.md) | Array |
| 285 | Medium | [Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst) | [](solutions/0285-inorder-successor-in-bst.md) | BST |
| 287 | Medium | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number) | [](solutions/0287-find-the-duplicate-number.md) | Array, HashSet |
| 322 | Medium | [Coin Change](https://leetcode.com/problems/coin-change) | [](solutions/0322-coin-change.md) | Dynamic Programming |
| 346 | Easy | [Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream) | [](solutions/0287-moving-average-from-data-stream.md) | Queue |
| 349 | Easy | [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays) | [](solutions/0349-intersection-of-two-arrays.md) | Array |
| 359 | Easy | [Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter) | [](solutions/0359-logger-rate-limiter.md) | HashMap |
| 383 | Easy | [Ransom Note](https://leetcode.com/problems/ransom-note) | [](solutions/0383-ransom-note.md) | HashMap |
| 387 | Easy | [First Unique Character in a String](https://leetcode.com/problems/first-unique-character-in-a-string) | [](solutions/0387-first-unique-character-in-a-string.md) | String |
| 392 | Easy | [Is Subsequence](https://leetcode.com/problems/is-subsequence) | [](solutions/0392-is-subsequence.md) | Array, Two Pointers |
| 443 | Medium | [String Compression](https://leetcode.com/problems/string-compression) | [](solutions/0443-string-compression.md) | BST |
| 450 | Medium | [Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst) | [](solutions/0450-delete-node-in-a-bst.md) | BST |
| 509 | Easy | [Fibonacci Number](https://leetcode.com/problems/fibonacci-number) | [](solutions/0509-fibonacci-number.md) | Recursion |
| 511 | Easy | [Game Play Analysis I](https://leetcode.com/problems/game-play-analysis-i) | [](solutions/0511-game-play-analysis-i.md) | SQL |
| 542 | Medium | [01 Matrix](https://leetcode.com/problems/01-matrix) | [](solutions/0542-01-matrix.md) | BST |
| 543 | Easy | [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree) | [](solutions/0543-diameter-of-binary-tree.md) | BST |
| 547 | Medium | [Number of Provinces](https://leetcode.com/problems/number-of-provinces) | [](solutions/0547-number-of-provinces.md) | Union Find |
| 586 | Easy | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders) | [](solutions/0586-customer-placing-the-largest-number-of-orders.md) | SQL |
| 595 | Easy | [Big Countries](https://leetcode.com/problems/big-countries) | [](solutions/0595-big-countries.md) | SQL |
| 613 | Easy | [Shortest Distance in a Line](https://leetcode.com/problems/shortest-distance-in-a-line) | [](solutions/0613-shortest-distance-in-a-line.md) | SQL |
| 622 | Medium | [Design Circular Queue](https://leetcode.com/problems/design-circular-queue) | [](solutions/0622-design-circular-queue.md) | Array |
| 627 | Easy | [Swap Salary](https://leetcode.com/problems/swap-salary) | [](solutions/0627-swap-salary.md) | SQL |
| 684 | Medium | [Redundant Connection](https://leetcode.com/problems/redundant-connection) | [](solutions/0684-redundant-connection.md) | Union Find |
| 701 | Medium | [Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree) | [](solutions/0701-insert-into-a-binary-search-tree.md) | BST |
| 704 | Easy | [Binary Search](https://leetcode.com/problems/binary-search) | [](solutions/0704-binary-search.md) | Array, Binary Search |
| 709 | Easy | [To Lower Case](https://leetcode.com/problems/to-lower-case) | [](solutions/0709-to-lower-case.md) | String |
| 743 | Medium | [Network Delay Time](https://leetcode.com/problems/network-delay-time) | [](solutions/0746-network-delay-time.md) | Dijkstra's Algorithm |
| 746 | Easy | [Min Cost Climbing Stairs](https://leetcode.com/problems/min-cost-climbing-stairs) | [](solutions/0746-min-cost-climbing-stairs.md) | Dynamic Programming |
| 760 | Easy | [Find Anagram Mappings](https://leetcode.com/problems/find-anagram-mappings) | [](solutions/0760-find-anagram-mappings.md) | Array, HashTable |
| 771 | Easy | [Jewels and Stones](https://leetcode.com/problems/jewels-and-stones) | [](solutions/0771-jewels-and-stones.md) | Array, HashSet |
| 787 | Medium | [Cheapest Flights Within K Stops](https://leetcode.com/problems/cheapest-flights-within-k-stops) | [](solutions/0787-cheapest-flights-within-k-stops.md) | Dijkstra's Algorithm |
| 841 | Medium | [Keys and Rooms](https://leetcode.com/problems/keys-and-rooms) | [](solutions/0845-keys-and-rooms.md) | DFS |
| 845 | Medium | [Longest Mountain in Array](https://leetcode.com/problems/longest-mountain-in-array) | [](solutions/0845-longest-mountain-in-array.md) | Array |
| 896 | Easy | [Monotonic Array](https://leetcode.com/problems/monotonic-array) | [](solutions/0896-monotonic-array.md) | Array |
| 938 | Easy | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst) | [](solutions/0938-range-sum-of-bst.md) | BST |
| 947 | Medium | [Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column) | [](solutions/0947-most-stones-removed-with-same-row-or-column.md) | Union Find |
| 973 | Medium | [K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin) | [](solutions/0973-k-closest-points-to-origin.md) | Heap |
| 977 | Easy | [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array) | [](solutions/0977-squares-of-a-sorted-array.md) | Array, Two Pointers |
| 994 | Medium | [Rotting Oranges](https://leetcode.com/problems/rotting-oranges) | [](solutions/0994-rotting-oranges.md) | BST Pointers |
| 1008 | Medium | [Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal) | [](solutions/1008-construct-binary-search-tree-from-preorder-traversal.md) | BST |
| 1020 | Medium | [Number of Enclaves](https://leetcode.com/problems/number-of-enclaves) | [](solutions/1020-number-of-enclaves.md) | DFS |
| 1069 | Easy | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii) | [](solutions/1069-product-sales-analysis-ii.md) | SQL |
| 1091 | Medium | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix) | [](solutions/1091-shortest-path-in-binary-matrix.md) | BFS |
| 1108 | Easy | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address/) | [](solutions/1108-defanging-an-ip-address.md) | String |
| 1119 | Easy | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string/) | [](solutions/1119-remove-vowels-from-a-string.md) | String |
| 1162 | Medium | [As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible/) | [](solutions/1162-as-far-from-land-as-possible.md) | String |
| 1173 | Easy | [Single-Row Keyboard](https://leetcode.com/problems/single-row-keyboard/) | [](solutions/1173-single-row-keyboard.md) | String |
| 1200 | Easy | [Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference/) | [](solutions/1200-minimum-absolute-difference.md) | Array, Sorting |
| 1303 | Easy | [Find the Team Size](https://leetcode.com/problems/find-the-team-size) | [](solutions/1303-find-the-team-size.md) | SQL |
| 1334 | Medium | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/) | [](solutions/1334-find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance.md) | Dijkstra's Algorithm |
| 1350 | Easy | [Students With Invalid Departments](https://leetcode.com/problems/students-with-invalid-departments) | [](solutions/1350-students-with-invalid-departments.md) | SQL |
| 1378 | Easy | [Replace Employee ID With The Unique Identifier](https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier) | [](solutions/1378-replace-employee-id-with-the-unique-identifier.md) | SQL |
| 1431 | Easy | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/) | [](solutions/1431-kids-with-the-greatest-number-of-candies.md) | Array |
| 1464 | Easy | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/) | [](solutions/1464-maximum-product-of-two-elements-in-an-array.md) | Array |
| 1470 | Easy | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array/) | [](solutions/1470-shuffle-the-array.md) | Array |
| 1480 | Easy | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array/) | [](solutions/1480-running-sum-of-1d-array.md) | Array |
| 1512 | Easy | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs) | [](solutions/1512-number-of-good-pairs.md) | Array |
| 1571 | Easy | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager) | [](solutions/1571-warehouse-manager.md) | SQL |
| 1581 | Easy | [Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions) | [](solutions/1581-customer-who-visited-but-did-not-make-any-transactions.md) | SQL |
| 1587 | Easy | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) | [](solutions/1587-bank-account-summary-ii.md) | SQL |
| 1623 | Easy | [All Valid Triplets That Can Represent a Country](https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country) | [](solutions/1623-all-valid-triplets-that-can-represent-a-country.md) | SQL |
| 1672 | Easy | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth) | [](solutions/1672-richest-customer-wealth.md) | Array |
| 1683 | Easy | [Invalid Tweets](https://leetcode.com/problems/invalid-tweets) | [](solutions/1683-invalid-tweets.md) | SQL |
| 1693 | Easy | [Recyclable and Low Fat Products](https://leetcode.com/problems/daily-leads-and-partners) | [](solutions/1693-daily-leads-and-partners.md) | SQL |
| 1741 | Easy | [Find Total Time Spent by Each Employee](https://leetcode.com/problems/find-total-time-spent-by-each-employee) | [](solutions/1741-find-total-time-spent-by-each-employee.md) | SQL |
| 1757 | Easy | [Recyclable and Low Fat Products](https://leetcode.com/problems/recyclable-and-low-fat-products) | [](solutions/1757-recyclable-and-low-fat-products.md) | SQL |
| 1821 | Easy | [Find Customers With Positive Revenue this Year](https://leetcode.com/problems/find-customers-with-positive-revenue-this-year) | [](solutions/1821-find-customers-with-positive-revenue-this-year.md) | SQL |
| 1853 | Easy | [Convert Date Format](https://leetcode.com/problems/convert-date-format) | [](solutions/1853-convert-date-format.md) | SQL |## Snippets
### Convert List to int[]
```java
List list = new ArrayList<>();
int[] array = list.stream().mapToInt(i->i).toArray();
```
### Convert int[] to List
```java
int[] nums = new int[]{1, 2, 3};
List numList = Arrays.stream(nums).boxed().collect(Collectors.toList());
```