Skip to content

sumit-dhanorkar/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
November 8th 1544. Make The String Great $\text{\color{TealBlue}Easy}$ Stack Stack, String
November 7th 1323. Maximum 69 Number $\text{\color{TealBlue}Easy}$ Math or String Greedy, Math
November 6th 2136. Earliest Possible Day of Full Bloom $\text{\color{Red}Hard}$ Sorting Array, Greedy, Sorting
November 5th 2131. Longest Palindrome by Concatenating Two Letter Words $\text{\color{Dandelion}Medium}$ Counting or Hash Table Array, Counting, Greedy, Hash Table, String
November 4th 345. Reverse Vowels of a String $\text{\color{TealBlue}Easy}$ Two Pointers String, Two Pointers


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
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
238 Product of Array Except Self Java $\text{\color{Dandelion}Medium}$ Array, Prefix Sum
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
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
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
929 Unique Email Addresses Java $\text{\color{TealBlue}Easy}$ Array, Hash Table, String
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
985 Sum of Even Numbers After Queries Java $\text{\color{Dandelion}Medium}$ Array, Simulation
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
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
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
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
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
2176 Count Equal and Divisible Pairs in an Array Java $\text{\color{TealBlue}Easy}$ Array
2438 Range Product Queries of Powers Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation, Prefix Sum

⬆️Back To Top


Backtracking

# Problem Solution Difficulty Topics Note
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


Binary Search

# Problem Solution Difficulty Topics Note
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

⬆️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


Counting

# Problem Solution Difficulty Topics Note
383 Ransom Note Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String 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

⬆️Back To Top


Dynamic Programming

# Problem Solution Difficulty Topics Note
368 Largest Divisible Subset Java $\text{\color{Dandelion}Medium}$ Array, Dynamic Programming, Math, Sorting
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
593 Valid Square Java $\text{\color{Dandelion}Medium}$ Geometry, Math
812 Largest Triangle Area Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math

⬆️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

⬆️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
49 Group Anagrams Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, String
383 Ransom Note Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Counting Array
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
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
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
2351 First Letter to Appear Twice Java $\text{\color{TealBlue}Easy}$ Counting, Hash Table, String Solution Using Counting

⬆️Back To Top


Heap (Priority Queue)

# Problem Solution Difficulty Topics Note
1337 The K Weakest Rows in a Matrix Java $\text{\color{TealBlue}Easy}$ Array, Binary Search, Heap (Priority Queue), Matrix, Sorting Solution Using Sorting

⬆️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
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
523 Continuous Subarray Sum Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Math, Prefix Sum
593 Valid Square Java $\text{\color{Dandelion}Medium}$ Geometry, Math
812 Largest Triangle Area Java $\text{\color{TealBlue}Easy}$ Array, Geometry, Math
976 Largest Perimeter Triangle Java $\text{\color{TealBlue}Easy}$ Array, Greedy, Math, Sorting
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

⬆️Back To Top


Matrix

# Problem Solution Difficulty Topics Note
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

⬆️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
1480 Running Sum of 1D Array Java $\text{\color{TealBlue}Easy}$ Array, Prefix Sum
2438 Range Product Queries of Powers Java $\text{\color{Dandelion}Medium}$ Array, Bit Manipulation, Prefix Sum

⬆️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
645 Set Mismatch Java $\text{\color{TealBlue}Easy}$ Array, Bit Manipulation, Hash Table, Sorting Solution Using Bit Manipulation or Hash Table
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
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
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

⬆️Back To Top


Stack

# Problem Solution Difficulty Topics Note
1544 Make The String Great Java $\text{\color{TealBlue}Easy}$ Stack, String

⬆️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
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
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
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
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
2437 Number of Valid Clock Times Java $\text{\color{TealBlue}Easy}$ Enumeration, String

⬆️Back To Top


Two Pointers

# Problem Solution Difficulty Topics Note
151 Reverse Words in a String Java $\text{\color{Dandelion}Medium}$ String, Two Pointers Solution Using Collections
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
948 Bag of Tokens Java $\text{\color{Dandelion}Medium}$ Array, Greedy, Sorting, Two Pointers
1679 Max Number of K-Sum Pairs Java $\text{\color{Dandelion}Medium}$ Array, Hash Table, Sorting, Two Pointers Solution Using Hash Table

⬆️Back To Top


About

LeetCode Solutions in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%