Skip to content

dsoumgit/leetcode-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

LeetCode Java Solutions


     

Hi 👋, I'm Chee Hwa and welcome to LeetCode Solutions in Java.

As I'm new to LeetCode and programming in general, I'm practicing everyday and hope to share my solutions and learnings with you.

  • Exclusively on Java
  • Beginner problems
  • Daily Challenge if within my ability


Latest Solutions


Date Problem Difficulty Solution Topics
January 9th 130. Surrounded Regions $\text{\color{Dandelion}Medium}$ Breadth-First Search Array, Breadth-First Search, Matrix,
January 8th 130. Surrounded Regions $\text{\color{Dandelion}Medium}$ Depth-First Search Array, Depth-First Search, Matrix,
January 7th 922. Sort Array By Parity II $\text{\color{TealBlue}Easy}$ Sorting & Two Pointers Array, Sorting, Two Pointers
January 6th 905. Sort Array By Parity $\text{\color{TealBlue}Easy}$ Sorting & Two Pointers Array, Sorting, Two Pointers
January 5th 200. Number of Islands $\text{\color{Dandelion}Medium}$ Union Find Array, Matrix, Union Find


Topics

The problem sets and solutions are grouped into Topics as stated in LeetCode.



Array

# Problem Solution Difficulty Topics Note
1 Two Sum Java $\text{\color{TealBlue}Easy}$ Array, Hash Table
26 Remove Duplicates from Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
27 Remove Element Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
36 Valid Sudoku Java without or with Hash Table $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix
37 Sudoku Solver Java $\text{\color{Red}Hard}$ Array, Backtracking, Matrix
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
73 Set Matrix Zeroes Java with Array, Hash Table or In-Place $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix
79 Word Search Java $\text{\color{Dandelion}Medium}$ Array, Backtracking, Matrix
80 Remove Duplicates from Sorted Array II Java $\text{\color{Dandelion}Medium}$ Array, Two Pointers
88 Merge Sorted Array Java with Sorting or Two Pointers $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
130 Surrounded Regions Java with Breadth-First Search or Depth-First Search $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix,
200 Number of Islands Java with Breadth-First Search, Depth-First Search or Union Find $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Union Find
238 Product of Array Except Self Java $\text{\color{Dandelion}Medium}$ Array, Prefix Sum
283 Move Zeroes Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
334 Increasing Triplet Subsequence Java $\text{\color{Dandelion}Medium}$ Array, Greedy
368 Largest Divisible Subset Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Math, Sorting
393 UTF-8 Validation Java without or with Bit Manipulation $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation
485 Maximum Consecutive Ones Java $\text{\color{TealBlue}Easy}$ Array
496 Next Greater Element I Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, Monotonic Stack, Stack
503 Next Greater Element II Java $\text{\color{Dandelion}Medium}$ Array, Monotonic Stack, Stack
523 Continuous Subarray Sum Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Math, Prefix Sum
560 Subarray Sum Equals K Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum
609 Find Duplicate File in System Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, String
645 Set Mismatch Java with Bit Manipulation, Hash Table or Sorting $\text{\color{TealBlue}Easy}$ Array, Bit Manipulation, Hash Table, Sorting
746 Min Cost Climbing Stairs Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Array, Dynamic Programming
766 Toeplitz Matrix Java $\text{\color{TealBlue}Easy}$ Array, Matrix Follow up: One Row at a Time and One Column at a Time
812 Largest Triangle Area Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
835 Image Overlap Java with Bit Manipulation or Hash Table $\text{\color{Dandelion}Medium}$ Array, Matrix
905 Sort Array By Parity Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
922 Sort Array By Parity II Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
929 Unique Email Addresses Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
941 Valid Mountain Array Java $\text{\color{TealBlue}Easy}$ Array
948 Bag of Tokens Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Sorting, Two Pointers
974 Subarray Sums Divisible by K Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum
976 Largest Perimeter Triangle Java $\text{\color{TealBlue}Easy}$ Array, Greedy, Math, Sorting
977 Squares of a Sorted Array Java with Sorting or Two Pointers $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
985 Sum of Even Numbers After Queries Java $\text{\color{Dandelion}Medium}$ Array, Simulation
1037 Valid Boomerang Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
1089 Duplicate Zeros Java without or with Two Pointers $\text{\color{TealBlue}Easy}$ Array, Two Pointers
1239 Maximum Length of a Concatenated String with Unique Characters Java with Backtracking or Bit Manipulation $\text{\color{Dandelion}Medium}$ Array, Backtracking, Bit Manipulation, String
1295 Find Numbers with Even Number of Digits Java $\text{\color{TealBlue}Easy}$ Array
1299 Replace Elements with Greatest Element on Right Side Java $\text{\color{TealBlue}Easy}$ Array
1337 The K Weakest Rows in a Matrix Java with Heap (Priority Queue) or Sorting $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting
1480 Running Sum of 1D Array Java $\text{\color{TealBlue}Easy}$ Array, Prefix Sum
1497 Check If Array Pairs Are Divisible by k Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table
1578 Minimum Time to Make Rope Colorful Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Greedy, String
1672 Richest Customer Wealth Java $\text{\color{TealBlue}Easy}$ Array, Matrix
1679 Max Number of K-Sum Pairs Java with Hash Table or Sorting & Two Pointers $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, Two Pointers
1711 Count Good Meals Java $\text{\color{Dandelion}Medium}$ Array, Hash Table
1834 Single-Threaded CPU Java $\text{\color{Dandelion}Medium}$ Array, Heap (Priority Queue), Sorting
1865 Finding Pairs With a Certain Sum Java $\text{\color{Dandelion}Medium}$ Array, Design, Hash Table
1979 Find Greatest Common Divisor of Array Java $\text{\color{TealBlue}Easy}$ Array, Math, Number Theory
1995 Count Special Quadruplets Java $\text{\color{TealBlue}Easy}$ Array, Enumeration Solution Using Hash Table
2007 Find Original Array From Doubled Array Java with Hash Table, Queue or Counting Array $\text{\color{Dandelion}Medium}$ Array, Greedy, Hash Table, Sorting
2023 Number of Pairs of Strings With Concatenation Equal to Target Java $\text{\color{Dandelion}Medium}$ Array, String
2131 Longest Palindrome by Concatenating Two Letter Words Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Counting, Greedy, Hash Table, String
2133 Check if Every Row and Column Contains All Numbers Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Array, Hash Table, Matrix
2136 Earliest Possible Day of Full Bloom Java $\text{\color{Red}Hard}$ Array, Greedy, Sorting
2176 Count Equal and Divisible Pairs in an Array Java $\text{\color{TealBlue}Easy}$ Array
2389 Longest Subsequence With Limited Sum Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Greedy, Prefix Sum, Sorting
2395 Find Subarrays With Equal Sum Java $\text{\color{TealBlue}Easy}$ Array, Hash Table
2399 Check Distances Between Same Letters Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
2438 Range Product Queries of Powers Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation, Prefix Sum
2452 Words Within Two Edits of Dictionary Java $\text{\color{Dandelion}Medium}$ Array, String
2453 Destroy Sequential Targets Java $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table
2454 Next Greater Element IV Java $\text{\color{Red}Hard}$ Array, Monotonic Stack, Stack

⬆️Back To Top


Backtracking

# Problem Solution Difficulty Topics Note
37 Sudoku Solver Java $\text{\color{Red}Hard}$ Array, Backtracking, Matrix
79 Word Search Java $\text{\color{Dandelion}Medium}$ Array, Backtracking, Matrix
797 All Paths From Source to Target Java $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search, Depth-First Search, Graph Solution Using Breadth-First Search, Depth-First Search (Iterative) or Depth-First Search (Recursive)
967 Numbers With Same Consecutive Differences Java $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search Solution Using Breadth-First Search
1239 Maximum Length of a Concatenated String with Unique Characters Java $\text{\color{Dandelion}Medium}$ Array, Backtracking, Bit Manipulation, String Solution Using Bit Manipulation

⬆️Back To Top


# Problem Solution Difficulty Topics Note
374 Guess Number Higher or Lower Java $\text{\color{TealBlue}Easy}$ Binary Search, Interactive
1337 The K Weakest Rows in a Matrix Java with Heap (Priority Queue) or Sorting $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting Solution Using Linear Search
2389 Longest Subsequence With Limited Sum Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Greedy, Prefix Sum, Sorting

⬆️Back To Top


Bit Manipulation

# Problem Solution Difficulty Topics Note
29 Divide Two Integers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math
371 Sum of Two Integers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math
393 UTF-8 Validation Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation
645 Set Mismatch Java $\text{\color{TealBlue}Easy}$ Array, Bit Manipulation, Hash Table, Sorting Solution Using Hash Table or Sorting
1239 Maximum Length of a Concatenated String with Unique Characters Java $\text{\color{Dandelion}Medium}$ Array, Backtracking, Bit Manipulation, String Solution Using Backtracking
1342 Number of Steps to Reduce a Number to Zero Java $\text{\color{TealBlue}Easy}$ Bit Manipulation, Math Solution Using Math
1486 XOR Operation in an Array Java $\text{\color{TealBlue}Easy}$ Bit Manipulation, Math
1680 Concatenation of Consecutive Binary Numbers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math, Simulation Solution Using Math
2438 Range Product Queries of Powers Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation, Prefix Sum

⬆️Back To Top


Brainteaser

# Problem Solution Difficulty Topics Note
1033 Moving Stones Until Consecutive Java $\text{\color{Dandelion}Medium}$ Brainteaser, Math

⬆️Back To Top


# Problem Solution Difficulty Topics Note
130 Surrounded Regions Java $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Solution Using Depth-First Search
200 Number of Islands Java $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Union Find Solution Using Depth-First Search or Union Find
797 All Paths From Source to Target Java $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search, Depth-First Search, Graph Solution Using Depth-First Search (Backtracking), Depth-First Search (Iterative) or Depth-First Search (Recursive)
967 Numbers With Same Consecutive Differences Java $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search Solution Using Backtracking
1971 Find if Path Exists in Graph Java $\text{\color{TealBlue}Easy}$ Breadth-First Search, Depth-First Search, Graph, Union Find Solution Using Depth-First Search (Iterative), Depth-First Search (Recursive) or Union Find

⬆️Back To Top


Counting

# Problem Solution Difficulty Topics Note
383 Ransom Note Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Hash Table
1497 Check If Array Pairs Are Divisible by k Java $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table Solution Using Hash Table
2131 Longest Palindrome by Concatenating Two Letter Words Java $\text{\color{Dandelion}Medium}$ Array, Counting, Greedy, Hash Table, String Solution Using Hash Table
2351 First Letter to Appear Twice Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Hash Table
2453 Destroy Sequential Targets Java $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table

⬆️Back To Top


Data Stream

# Problem Solution Difficulty Topics Note
295 Find Median from Data Stream Java $\text{\color{Red}Hard}$ Data Stream, Design, Heap (Priority Queue), Sorting, Two Pointers

⬆️Back To Top


or Union Find
# Problem Solution Difficulty Topics Note
130 Surrounded Regions Java $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Solution Using Breadth-First Search
200 Number of Islands Java $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Union Find Solution Using Breadth-First Search or Union Find
797 All Paths From Source to Target Java with Depth-First Search (Backtracking), Depth-First Search (Iterative) or Depth-First Search (Recursive) $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search, Depth-First Search, Graph Solution Using Breadth-First Search
1971 Find if Path Exists in Graph Java with Depth-First Search (Iterative) or Depth-First Search (Recursive) $\text{\color{TealBlue}Easy}$ Breadth-First Search, Depth-First Search, Graph, Union Find Solution Using Breadth-First Search

⬆️Back To Top


Design

# Problem Solution Difficulty Topics Note
295 Find Median from Data Stream Java $\text{\color{Red}Hard}$ Data Stream, Design, Heap (Priority Queue), Sorting, Two Pointers
707 Design Linked List Java with Singly Linked List or Doubly Linked List $\text{\color{Dandelion}Medium}$ Design, Linked List
1865 Finding Pairs With a Certain Sum Java $\text{\color{Dandelion}Medium}$ Array, Design, Hash Table

⬆️Back To Top


Dynamic Programming

# Problem Solution Difficulty Topics Note
70 Climbing Stairs Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization
264 Ugly Number II Java $\text{\color{Dandelion}Medium}$ Dynamic Programming, Hash Table, Heap (Priority Queue), Math Solution Using Heap (Priority Queue)
368 Largest Divisible Subset Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Math, Sorting
509 Fibonacci Number Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization, Recursion
746 Min Cost Climbing Stairs Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Array, Dynamic Programming
1578 Minimum Time to Make Rope Colorful Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Greedy, String

⬆️Back To Top


Enumeration

# Problem Solution Difficulty Topics Note
1995 Count Special Quadruplets Java $\text{\color{TealBlue}Easy}$ Array, Enumeration Solution Using Hash Table
2240 Number of Ways to Buy Pens and Pencils Java $\text{\color{Dandelion}Medium}$ Enumeration, Math
2437 Number of Valid Clock Times Java $\text{\color{TealBlue}Easy}$ Enumeration, String

⬆️Back To Top


Geometry

# Problem Solution Difficulty Topics Note
223 Rectangle Area Java $\text{\color{Dandelion}Medium}$ Geometry, Math
593 Valid Square Java $\text{\color{Dandelion}Medium}$ Geometry, Math
812 Largest Triangle Area Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
836 Rectangle Overlap Java $\text{\color{TealBlue}Easy}$ Geometry, Math
1037 Valid Boomerang Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math

⬆️Back To Top


Graph

# Problem Solution Difficulty Topics Note
797 All Paths From Source to Target Java with Breadth-First Search, Depth-First Search (Backtracking), Depth-First Search (Iterative) or Depth-First Search (Recursive) $\text{\color{Dandelion}Medium}$ Backtracking, Breadth-First Search, Depth-First Search, Graph
1971 Find if Path Exists in Graph Java with Breadth-First Search, Depth-First Search (Iterative), Depth-First Search (Recursive) or Union Find $\text{\color{TealBlue}Easy}$ Breadth-First Search, Depth-First Search, Graph, Union Find

⬆️Back To Top


Greedy

# Problem Solution Difficulty Topics Note
334 Increasing Triplet Subsequence Java $\text{\color{Dandelion}Medium}$ Array, Greedy
948 Bag of Tokens Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Sorting, Two Pointers
976 Largest Perimeter Triangle Java $\text{\color{TealBlue}Easy}$ Array, Greedy, Math, Sorting
1323 Maximum 69 Number Java with Math or String $\text{\color{TealBlue}Easy}$ Greedy, Math
1328 Break a Palindrome Java $\text{\color{Dandelion}Medium}$ Greedy, String
1578 Minimum Time to Make Rope Colorful Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Greedy, String
2007 Find Original Array From Doubled Array Java with Hash Table, Queue or Counting Array $\text{\color{Dandelion}Medium}$ Array, Greedy, Hash Table, Sorting
2131 Longest Palindrome by Concatenating Two Letter Words Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Counting, Greedy, Hash Table, String
2136 Earliest Possible Day of Full Bloom Java $\text{\color{Red}Hard}$ Array, Greedy, Sorting
2389 Longest Subsequence With Limited Sum Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Greedy, Prefix Sum, Sorting

⬆️Back To Top


Hash Table

# Problem Solution Difficulty Topics Note
1 Two Sum Java $\text{\color{TealBlue}Easy}$ Array, Hash Table
12 Integer to Roman Java $\text{\color{Dandelion}Medium}$ Hash Table, Math, String
13 Roman to Integer Java $\text{\color{TealBlue}Easy}$ Hash Table, Math, String Solution Without Hash Table
36 Valid Sudoku Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix Solution without Hash Table
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
73 Set Matrix Zeroes Java with Array, Hash Table or In-Place $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix
264 Ugly Number II Java with Dynamic Programming or Heap (Priority Queue) $\text{\color{Dandelion}Medium}$ Dynamic Programming, Hash Table, Heap (Priority Queue), Math
290 Word Pattern Java $\text{\color{TealBlue}Easy}$ Hash Table, String
383 Ransom Note Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Counting Array
496 Next Greater Element I Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, Monotonic Stack, Stack
523 Continuous Subarray Sum Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Math, Prefix Sum
560 Subarray Sum Equals K Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum
609 Find Duplicate File in System Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, String
645 Set Mismatch Java $\text{\color{TealBlue}Easy}$ Array, Bit Manipulation, Hash Table, Sorting Solution Using Bit Manipulation or Sorting
929 Unique Email Addresses Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
974 Subarray Sums Divisible by K Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum Solution Using Counting
1497 Check If Array Pairs Are Divisible by k Java $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table Solution Using Counting
1679 Max Number of K-Sum Pairs Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, Two Pointers Solution Using Sorting & Two Pointers
1711 Count Good Meals Java $\text{\color{Dandelion}Medium}$ Array, Hash Table
1832 Check if the Sentence is Pangram Java $\text{\color{TealBlue}Easy}$ Hash Table, String Solution Without Hash Table
1865 Finding Pairs With a Certain Sum Java $\text{\color{Dandelion}Medium}$ Array, Design, Hash Table
1935 Maximum Number of Words You Can Type Java $\text{\color{TealBlue}Easy}$ Hash Table, String
2007 Find Original Array From Doubled Array Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Hash Table, Sorting Solution Using Queue or Counting Array
2131 Longest Palindrome by Concatenating Two Letter Words Java $\text{\color{Dandelion}Medium}$ Array, Counting, Greedy, Hash Table, String Solution Using Counting
2133 Check if Every Row and Column Contains All Numbers Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, Matrix Solution Without Hash Table
2351 First Letter to Appear Twice Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Counting
2395 Find Subarrays With Equal Sum Java $\text{\color{TealBlue}Easy}$ Array, Hash Table
2399 Check Distances Between Same Letters Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, String Solution Without Hash Table
2451 Odd String Difference Java $\text{\color{TealBlue}Easy}$ Hash Table, Math, String Solution Without Hash Table
2453 Destroy Sequential Targets Java $\text{\color{Dandelion}Medium}$ Array, Counting, Hash Table

⬆️Back To Top


Heap (Priority Queue)

# Problem Solution Difficulty Topics Note
264 Ugly Number II Java $\text{\color{Dandelion}Medium}$ Dynamic Programming, Hash Table, Heap (Priority Queue), Math Solution Using Dynamic Programming
295 Find Median from Data Stream Java $\text{\color{Red}Hard}$ Data Stream, Design, Heap (Priority Queue), Sorting, Two Pointers
1337 The K Weakest Rows in a Matrix Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting Solution Using Sorting
1834 Single-Threaded CPU Java $\text{\color{Dandelion}Medium}$ Array, Heap (Priority Queue), Sorting

⬆️Back To Top


Interactive

# Problem Solution Difficulty Topics Note
374 Guess Number Higher or Lower Java $\text{\color{TealBlue}Easy}$ Binary Search, Interactive

⬆️Back To Top


Linked List

# Problem Solution Difficulty Topics Note
19 Remove Nth Node From End of List Java with One Pass or Two Passes $\text{\color{Dandelion}Medium}$ Linked List, Two Pointers
707 Design Linked List Java with Singly Linked List or Doubly Linked List $\text{\color{Dandelion}Medium}$ Design, Linked List
876 Middle of the Linked List Java $\text{\color{TealBlue}Easy}$ Linked List, Two Pointers
2095 Delete the Middle Node of a Linked List Java $\text{\color{Dandelion}Medium}$ Linked List, Two Pointers

⬆️Back To Top


Math

# Problem Solution Difficulty Topics Note
12 Integer to Roman Java $\text{\color{Dandelion}Medium}$ Hash Table, Math, String
13 Roman to Integer Java $\text{\color{TealBlue}Easy}$ Hash Table, Math, String Solution Using Hash Table
29 Divide Two Integers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math
70 Climbing Stairs Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization
223 Rectangle Area Java $\text{\color{Dandelion}Medium}$ Geometry, Math
263 Ugly Number Java $\text{\color{TealBlue}Easy}$ Math
264 Ugly Number II Java with Dynamic Programming or Heap (Priority Queue) $\text{\color{Dandelion}Medium}$ Dynamic Programming, Hash Table, Heap (Priority Queue), Math
368 Largest Divisible Subset Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Math, Sorting
371 Sum of Two Integers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math
412 Fizz Buzz Java $\text{\color{TealBlue}Easy}$ Math, Simulation, String
492 Construct the Rectangle Java $\text{\color{TealBlue}Easy}$ Math
509 Fibonacci Number Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization, Recursion
523 Continuous Subarray Sum Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Math, Prefix Sum
556 Next Greater Element III Java $\text{\color{Dandelion}Medium}$ Math, String, Two Pointers
593 Valid Square Java $\text{\color{Dandelion}Medium}$ Geometry, Math
812 Largest Triangle Area Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
836 Rectangle Overlap Java $\text{\color{TealBlue}Easy}$ Geometry, Math
976 Largest Perimeter Triangle Java $\text{\color{TealBlue}Easy}$ Array, Greedy, Math, Sorting
1033 Moving Stones Until Consecutive Java $\text{\color{Dandelion}Medium}$ Brainteaser, Math
1037 Valid Boomerang Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
1071 Greatest Common Divisor of Strings Java $\text{\color{TealBlue}Easy}$ Math, String
1103 Distribute Candies to People Java $\text{\color{TealBlue}Easy}$ Math, Simulation
1154 Day of the Year Java $\text{\color{TealBlue}Easy}$ Math, String
1323 Maximum 69 Number Java $\text{\color{TealBlue}Easy}$ Greedy, Math Solution Using String
1342 Number of Steps to Reduce a Number to Zero Java $\text{\color{TealBlue}Easy}$ Bit Manipulation, Math Solution Using Bit Manipulation
1486 XOR Operation in an Array Java $\text{\color{TealBlue}Easy}$ Bit Manipulation, Math
1680 Concatenation of Consecutive Binary Numbers Java $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math, Simulation Solution Using Bit Manipulation
1979 Find Greatest Common Divisor of Array Java $\text{\color{TealBlue}Easy}$ Array, Math, Number Theory
2169 Count Operations to Obtain Zero Java $\text{\color{TealBlue}Easy}$ Math, Simulation
2240 Number of Ways to Buy Pens and Pencils Java $\text{\color{Dandelion}Medium}$ Enumeration, Math
2413 Smallest Even Multiple Java $\text{\color{TealBlue}Easy}$ Math, Number Theory
2451 Odd String Difference Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Hash Table, Math, String

⬆️Back To Top


Matrix

# Problem Solution Difficulty Topics Note
36 Valid Sudoku Java without or with Hash Table $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix
37 Sudoku Solver Java $\text{\color{Red}Hard}$ Array, Backtracking, Matrix
73 Set Matrix Zeroes Java with Array, Hash Table or In-Place $\text{\color{Dandelion}Medium}$ Array, Hash Table, Matrix
79 Word Search Java $\text{\color{Dandelion}Medium}$ Array, Backtracking, Matrix
130 Surrounded Regions Java with Breadth-First Search or Depth-First Search $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix,
200 Number of Islands Java with Breadth-First Search, Depth-First Search or Union Find $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Union Find
766 Toeplitz Matrix Java $\text{\color{TealBlue}Easy}$ Array, Matrix Follow up: One Row at a Time and One Column at a Time
835 Image Overlap Java with Bit Manipulation or Hash Table $\text{\color{Dandelion}Medium}$ Array, Matrix
1337 The K Weakest Rows in a Matrix Java with Heap (Priority Queue) or Sorting $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting
1672 Richest Customer Wealth Java $\text{\color{TealBlue}Easy}$ Array, Matrix
2133 Check if Every Row and Column Contains All Numbers Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Array, Hash Table, Matrix

⬆️Back To Top


Memoization

# Problem Solution Difficulty Topics Note
70 Climbing Stairs Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization
509 Fibonacci Number Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization, Recursion

⬆️Back To Top


Monotonic Stack

# Problem Solution Difficulty Topics Note
496 Next Greater Element I Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, Monotonic Stack, Stack
503 Next Greater Element II Java $\text{\color{Dandelion}Medium}$ Array, Monotonic Stack, Stack
2454 Next Greater Element IV Java $\text{\color{Red}Hard}$ Array, Monotonic Stack, Stack

⬆️Back To Top


Number Theory

# Problem Solution Difficulty Topics Note
1979 Find Greatest Common Divisor of Array Java $\text{\color{TealBlue}Easy}$ Array, Math, Number Theory
2413 Smallest Even Multiple Java $\text{\color{TealBlue}Easy}$ Math, Number Theory

⬆️Back To Top


Prefix Sum

# Problem Solution Difficulty Topics Note
238 Product of Array Except Self Java $\text{\color{Dandelion}Medium}$ Array, Prefix Sum
523 Continuous Subarray Sum Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Math, Prefix Sum
560 Subarray Sum Equals K Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum
974 Subarray Sums Divisible by K Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Hash Table, Prefix Sum
1480 Running Sum of 1D Array Java $\text{\color{TealBlue}Easy}$ Array, Prefix Sum
2389 Longest Subsequence With Limited Sum Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Greedy, Prefix Sum, Sorting
2438 Range Product Queries of Powers Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation, Prefix Sum

⬆️Back To Top


Recursion

# Problem Solution Difficulty Topics Note
509 Fibonacci Number Java with Dynamic Programming - Tabulation or Memoization $\text{\color{TealBlue}Easy}$ Dynamic Programming, Math, Memoization, Recursion

⬆️Back To Top


Simulation

# Problem Solution Difficulty Topics Note
412 Fizz Buzz Java $\text{\color{TealBlue}Easy}$ Math, Simulation, String
985 Sum of Even Numbers After Queries Java $\text{\color{Dandelion}Medium}$ Array, Simulation
1103 Distribute Candies to People Java $\text{\color{TealBlue}Easy}$ Math, Simulation
1680 Concatenation of Consecutive Binary Numbers Java with Bit Manipulation or Math $\text{\color{Dandelion}Medium}$ Bit Manipulation, Math, Simulation
2169 Count Operations to Obtain Zero Java $\text{\color{TealBlue}Easy}$ Math, Simulation

⬆️Back To Top


Sorting

# Problem Solution Difficulty Topics Note
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
88 Merge Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers Solution Using Two Pointers
295 Find Median from Data Stream Java with Heap (Priority Queue) $\text{\color{Red}Hard}$ Data Stream, Design, Heap (Priority Queue), Sorting, Two Pointers Use of Sorting & Two Pointers resulted in TLE (Time Limit Exceed) for large datasets.
645 Set Mismatch Java $\text{\color{TealBlue}Easy}$ Array, Bit Manipulation, Hash Table, Sorting Solution Using Bit Manipulation or Hash Table
905 Sort Array By Parity Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
922 Sort Array By Parity II Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
948 Bag of Tokens Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Sorting, Two Pointers
976 Largest Perimeter Triangle Java $\text{\color{TealBlue}Easy}$ Array, Greedy, Math, Sorting
977 Squares of a Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers Solution Using Two Pointers
1337 The K Weakest Rows in a Matrix Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting Solution Using Heap (Priority Queue)
1679 Max Number of K-Sum Pairs Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, Two Pointers Solution Using Hash Table
1834 Single-Threaded CPU Java $\text{\color{Dandelion}Medium}$ Array, Heap (Priority Queue), Sorting
2007 Find Original Array From Doubled Array Java with Hash Table or Queue $\text{\color{Dandelion}Medium}$ Array, Greedy, Hash Table, Sorting Solution Using Counting Array
2136 Earliest Possible Day of Full Bloom Java $\text{\color{Red}Hard}$ Array, Greedy, Sorting
2389 Longest Subsequence With Limited Sum Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Greedy, Prefix Sum, Sorting

⬆️Back To Top


Stack

# Problem Solution Difficulty Topics Note
496 Next Greater Element I Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, Monotonic Stack, Stack
503 Next Greater Element II Java $\text{\color{Dandelion}Medium}$ Array, Monotonic Stack, Stack
1047 Remove All Adjacent Duplicates In String Java $\text{\color{TealBlue}Easy}$ Stack, String
1544 Make The String Great Java $\text{\color{TealBlue}Easy}$ Stack, String
2454 Next Greater Element IV Java $\text{\color{Red}Hard}$ Array, Monotonic Stack, Stack

⬆️Back To Top


String

# Problem Solution Difficulty Topics Note
12 Integer to Roman Java $\text{\color{Dandelion}Medium}$ Hash Table, Math, String
13 Roman to Integer Java $\text{\color{TealBlue}Easy}$ Hash Table, Math, String Solution Using Hash Table
38 Count and Say Java with Iterative or Recursive Algorithms $\text{\color{Dandelion}Medium}$ String
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
151 Reverse Words in a String Java with String or Collections Implementations $\text{\color{Dandelion}Medium}$ String, Two Pointers Solution Using Two Pointers
290 Word Pattern Java $\text{\color{TealBlue}Easy}$ Hash Table, String
344 Reverse String Java $\text{\color{TealBlue}Easy}$ String, Two Pointers
345 Reverse Vowels of a String Java $\text{\color{TealBlue}Easy}$ String, Two Pointers
368 Largest Divisible Subset Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Math, Sorting
383 Ransom Note Java with Counting Array or Hash Table $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String
412 Fizz Buzz Java $\text{\color{TealBlue}Easy}$ Math, Simulation, String
556 Next Greater Element III Java $\text{\color{Dandelion}Medium}$ Math, String, Two Pointers
609 Find Duplicate File in System Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, String
929 Unique Email Addresses Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
1047 Remove All Adjacent Duplicates In String Java $\text{\color{TealBlue}Easy}$ Stack, String
1071 Greatest Common Divisor of Strings Java $\text{\color{TealBlue}Easy}$ Math, String
1154 Day of the Year Java $\text{\color{TealBlue}Easy}$ Math, String
1239 Maximum Length of a Concatenated String with Unique Characters Java with Backtracking or Bit Manipulation $\text{\color{Dandelion}Medium}$ Array, Backtracking, Bit Manipulation, String
1328 Break a Palindrome Java $\text{\color{Dandelion}Medium}$ Greedy, String
1544 Make The String Great Java $\text{\color{TealBlue}Easy}$ Stack, String
1578 Minimum Time to Make Rope Colorful Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Greedy, String
1592 Rearrange Spaces Between Words Java $\text{\color{TealBlue}Easy}$ String
1832 Check if the Sentence is Pangram Java $\text{\color{TealBlue}Easy}$ Hash Table, String Solution Using Hash Table
1935 Maximum Number of Words You Can Type Java $\text{\color{TealBlue}Easy}$ Hash Table, String
2023 Number of Pairs of Strings With Concatenation Equal to Target Java $\text{\color{Dandelion}Medium}$ Array, String
2131 Longest Palindrome by Concatenating Two Letter Words Java with Counting or Hash Table $\text{\color{Dandelion}Medium}$ Array, Counting, Greedy, Hash Table, String
2315 Count Asterisks Java $\text{\color{TealBlue}Easy}$ String
2351 First Letter to Appear Twice Java with Counting or Hash Table $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String
2399 Check Distances Between Same Letters Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
2437 Number of Valid Clock Times Java $\text{\color{TealBlue}Easy}$ Enumeration, String
2451 Odd String Difference Java without or with Hash Table $\text{\color{TealBlue}Easy}$ Hash Table, Math, String
2452 Words Within Two Edits of Dictionary Java $\text{\color{Dandelion}Medium}$ Array, String

⬆️Back To Top


Two Pointers

# Problem Solution Difficulty Topics Note
19 Remove Nth Node From End of List Java with One Pass or Two Passes $\text{\color{Dandelion}Medium}$ Linked List, Two Pointers
26 Remove Duplicates from Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
27 Remove Element Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
80 Remove Duplicates from Sorted Array II Java $\text{\color{Dandelion}Medium}$ Array, Two Pointers
88 Merge Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers Solution Using Sorting
151 Reverse Words in a String Java $\text{\color{Dandelion}Medium}$ String, Two Pointers Solution Using Collections
283 Move Zeroes Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers
295 Find Median from Data Stream Java with Heap (Priority Queue) $\text{\color{Red}Hard}$ Data Stream, Design, Heap (Priority Queue), Sorting, Two Pointers Use of Sorting & Two Pointers resulted in TLE (Time Limit Exceed) for large datasets.
344 Reverse String Java $\text{\color{TealBlue}Easy}$ String, Two Pointers
345 Reverse Vowels of a String Java $\text{\color{TealBlue}Easy}$ String, Two Pointers
556 Next Greater Element III Java $\text{\color{Dandelion}Medium}$ Math, String, Two Pointers
876 Middle of the Linked List Java $\text{\color{TealBlue}Easy}$ Linked List, Two Pointers
905 Sort Array By Parity Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
922 Sort Array By Parity II Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers
948 Bag of Tokens Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Sorting, Two Pointers
977 Squares of a Sorted Array Java $\text{\color{TealBlue}Easy}$ Array, Sorting, Two Pointers Solution Using Sorting
1089 Duplicate Zeros Java $\text{\color{TealBlue}Easy}$ Array, Two Pointers Solution Without Two Pointers
1679 Max Number of K-Sum Pairs Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, Two Pointers Solution Using Hash Table
2095 Delete the Middle Node of a Linked List Java $\text{\color{Dandelion}Medium}$ Linked List, Two Pointers

⬆️Back To Top


Union Find

# Problem Solution Difficulty Topics Note
200 Number of Islands Java $\text{\color{Dandelion}Medium}$ Array, Breadth-First Search, Depth-First Search, Matrix, Union Find Solution Using Breadth-First Search or Depth-First Search
1971 Find if Path Exists in Graph Java $\text{\color{TealBlue}Easy}$ Breadth-First Search, Depth-First Search, Graph, Union Find Solution Using Breadth-First Search, Depth-First Search (Iterative) or Depth-First Search (Recursive)

⬆️Back To Top


About

LeetCode Solutions in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%