Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

311 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LearnGitHub

LeetCode Solutions in Java

This repository contains my solutions to LeetCode problems solved during my Data Structures and Algorithms (DSA) practice journey.

About

The goal of this repository is to:

  • Improve problem-solving skills
  • Strengthen understanding of Data Structures and Algorithms
  • Track my coding progress
  • Prepare for coding interviews and competitive programming

All solutions are implemented in Java.

Repository Structure

Each file contains the solution to a specific LeetCode problem.

Example:

ThreeSum.java
ValidPalindrome2.java
StackAddAtBottom.java

Topics Covered

  • Arrays
  • Strings
  • Linked Lists
  • Stacks
  • Queues
  • Trees
  • Hashing
  • Recursion
  • Two Pointers
  • Sliding Window
  • Dynamic Programming
  • Greedy Algorithms

Problem Format

For each problem, I try to:

  1. Understand the problem statement.
  2. Develop a brute force program first and then later find an optimized approach.
  3. Implement the solution in Java.
  4. Analyze time and space complexity.

Progress

I will continuously update this repository as I solve more LeetCode problems.

Feel free to explore the solutions and suggest improvements.

LeetCode Topics

Hash Table

0003-longest-substring-without-repeating-characters
0205-isomorphic-strings
1331-rank-transform-of-an-array
1358-number-of-substrings-containing-all-three-characters
1365-how-many-numbers-are-smaller-than-the-current-number
1636-sort-array-by-increasing-frequency
3016-minimum-number-of-pushes-to-type-word-ii
3020-find-the-maximum-number-of-elements-in-subset
3312-sorted-gcd-pair-queries
3518-smallest-palindromic-rearrangement-ii
3532-path-existence-queries-in-a-graph-i
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

String

0003-longest-substring-without-repeating-characters
0071-simplify-path
0205-isomorphic-strings
0345-reverse-vowels-of-a-string
0541-reverse-string-ii
0557-reverse-words-in-a-string-iii
0680-valid-palindrome-ii
1081-smallest-subsequence-of-distinct-characters
1358-number-of-substrings-containing-all-three-characters
1456-maximum-number-of-vowels-in-a-substring-of-given-length
1967-number-of-strings-that-appear-as-substrings-in-word
3016-minimum-number-of-pushes-to-type-word-ii
3499-maximize-active-section-with-trade-i
3518-smallest-palindromic-rearrangement-ii
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii

Array

0137-single-number-ii
0162-find-peak-element
0167-two-sum-ii-input-array-is-sorted
0209-minimum-size-subarray-sum
0628-maximum-product-of-three-numbers
0643-maximum-average-subarray-i
0905-sort-array-by-parity
0922-sort-array-by-parity-ii
1288-remove-covered-intervals
1301-number-of-paths-with-max-score
1331-rank-transform-of-an-array
1365-how-many-numbers-are-smaller-than-the-current-number
1464-maximum-product-of-two-elements-in-an-array
1470-shuffle-the-array
1636-sort-array-by-increasing-frequency
1846-maximum-element-after-decreasing-and-rearranging
1929-concatenation-of-array
1967-number-of-strings-that-appear-as-substrings-in-word
1979-find-greatest-common-divisor-of-array
2812-find-the-safest-path-in-a-grid
3020-find-the-maximum-number-of-elements-in-subset
3286-find-a-safe-walk-through-a-grid
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii
3867-sum-of-gcd-of-formed-pairs

Divide and Conquer

3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Segment Tree

3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Merge Sort

3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii

Counting

3016-minimum-number-of-pushes-to-type-word-ii
3312-sorted-gcd-pair-queries
3518-smallest-palindromic-rearrangement-ii
3737-count-subarrays-with-majority-element-i

Prefix Sum

0209-minimum-size-subarray-sum
3312-sorted-gcd-pair-queries
3737-count-subarrays-with-majority-element-i
3739-count-subarrays-with-majority-element-ii
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii

Database

0610-triangle-judgement
0619-biggest-single-number
1731-the-number-of-employees-which-report-to-each-employee
1789-primary-department-for-each-employee

Enumeration

1291-sequential-digits
3020-find-the-maximum-number-of-elements-in-subset
3499-maximize-active-section-with-trade-i
3514-number-of-unique-xor-triplets-ii

Greedy

0680-valid-palindrome-ii
1081-smallest-subsequence-of-distinct-characters
1846-maximum-element-after-decreasing-and-rearranging
3016-minimum-number-of-pushes-to-type-word-ii
3534-path-existence-queries-in-a-graph-ii

Sorting

0628-maximum-product-of-three-numbers
0905-sort-array-by-parity
0922-sort-array-by-parity-ii
1288-remove-covered-intervals
1331-rank-transform-of-an-array
1365-how-many-numbers-are-smaller-than-the-current-number
1464-maximum-product-of-two-elements-in-an-array
1636-sort-array-by-increasing-frequency
1846-maximum-element-after-decreasing-and-rearranging
3016-minimum-number-of-pushes-to-type-word-ii
3534-path-existence-queries-in-a-graph-ii
3536-maximum-product-of-two-digits
3867-sum-of-gcd-of-formed-pairs

Sliding Window

0003-longest-substring-without-repeating-characters
0209-minimum-size-subarray-sum
0643-maximum-average-subarray-i
1358-number-of-substrings-containing-all-three-characters
1456-maximum-number-of-vowels-in-a-substring-of-given-length

Binary Search

0162-find-peak-element
0167-two-sum-ii-input-array-is-sorted
0209-minimum-size-subarray-sum
1954-minimum-garden-perimeter-to-collect-enough-apples
2812-find-the-safest-path-in-a-grid
3312-sorted-gcd-pair-queries
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways

Stack

0071-simplify-path
1081-smallest-subsequence-of-distinct-characters

Breadth-First Search

2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
2812-find-the-safest-path-in-a-grid
3286-find-a-safe-walk-through-a-grid

Union-Find

2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
2812-find-the-safest-path-in-a-grid
3532-path-existence-queries-in-a-graph-i

Heap (Priority Queue)

1464-maximum-product-of-two-elements-in-an-array
2812-find-the-safest-path-in-a-grid
3286-find-a-safe-walk-through-a-grid
3620-network-recovery-pathways

Matrix

1301-number-of-paths-with-max-score
2812-find-the-safest-path-in-a-grid
3286-find-a-safe-walk-through-a-grid

Graph Theory

2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components
3286-find-a-safe-walk-through-a-grid
3532-path-existence-queries-in-a-graph-i
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways

Shortest Path

3286-find-a-safe-walk-through-a-grid
3620-network-recovery-pathways

Simulation

1929-concatenation-of-array
3867-sum-of-gcd-of-formed-pairs

Dynamic Programming

1301-number-of-paths-with-max-score
3336-find-the-number-of-subsequences-with-equal-gcd
3534-path-existence-queries-in-a-graph-ii
3620-network-recovery-pathways

Topological Sort

3620-network-recovery-pathways

Depth-First Search

2492-minimum-score-of-a-path-between-two-cities
2685-count-the-number-of-complete-components

Two Pointers

0061-rotate-list
0167-two-sum-ii-input-array-is-sorted
0345-reverse-vowels-of-a-string
0541-reverse-string-ii
0557-reverse-words-in-a-string-iii
0680-valid-palindrome-ii
0905-sort-array-by-parity
0922-sort-array-by-parity-ii
3534-path-existence-queries-in-a-graph-ii
3867-sum-of-gcd-of-formed-pairs

Math

0628-maximum-product-of-three-numbers
1954-minimum-garden-perimeter-to-collect-enough-apples
1979-find-greatest-common-divisor-of-array
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3518-smallest-palindromic-rearrangement-ii
3536-maximum-product-of-two-digits
3658-gcd-of-odd-and-even-sums
3756-concatenate-non-zero-digits-and-multiply-by-sum-ii
3867-sum-of-gcd-of-formed-pairs

Bit Manipulation

0137-single-number-ii
3513-number-of-unique-xor-triplets-i
3514-number-of-unique-xor-triplets-ii
3534-path-existence-queries-in-a-graph-ii

Number Theory

1979-find-greatest-common-divisor-of-array
3312-sorted-gcd-pair-queries
3336-find-the-number-of-subsequences-with-equal-gcd
3658-gcd-of-odd-and-even-sums
3867-sum-of-gcd-of-formed-pairs

Combinatorics

3312-sorted-gcd-pair-queries
3518-smallest-palindromic-rearrangement-ii

Monotonic Stack

1081-smallest-subsequence-of-distinct-characters

Counting Sort

1365-how-many-numbers-are-smaller-than-the-current-number

Linked List

0061-rotate-list
0083-remove-duplicates-from-sorted-list

About

Nothing to tell yet

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages