Skip to content

ayushrawat220804/Leet-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

930 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions Repository

Welcome to my LeetCode solutions repository! 🚀
This repository is automatically updated with my solved LeetCode problems, organized in the following structure:

  • (problem_number, problem_name).cpp: Contains my solution to the problem with comments on time and space complexity.
  • README.md: Includes the full problem statement from LeetCode.
  • notes.md: An empty file for future notes or additional thoughts (created automatically).

How It Works

This repository is maintained using LeetHub, a simple Chrome extension that automates the process of pushing solved LeetCode problems to GitHub. It automatically creates the files mentioned above and comments my code with time and space complexity.

Thank You

A big shoutout to the developer of LeetHub for building such an awesome tool! It makes tracking and sharing my progress seamless. 🙌

LeetCode Topics

Two Pointers

0005-longest-palindromic-substring
0015-3sum
0031-next-permutation
0075-sort-colors
2265-partition-array-according-to-given-pivot
2414-move-pieces-to-obtain-a-string
2551-apply-operations-to-an-array
2707-merge-two-2d-arrays-by-summing-values
3018-make-string-a-subsequence-using-cyclic-increments

String

0005-longest-palindromic-substring
0952-word-subsets
1093-recover-a-tree-from-preorder-traversal
1170-shortest-common-supersequence
1460-number-of-substrings-containing-all-three-characters
1502-construct-k-palindrome-strings
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1524-string-matching-in-an-array
1537-maximum-score-after-splitting-a-string
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1915-check-if-one-string-swap-can-make-strings-equal
2021-remove-all-occurrences-of-a-substring
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2221-check-if-a-parentheses-string-can-be-valid
2292-counting-words-with-a-given-prefix
2300-construct-string-with-repeat-limit
2414-move-pieces-to-obtain-a-string
2456-construct-smallest-number-from-di-string
2463-minimum-recolors-to-get-k-consecutive-black-blocks
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges
3018-make-string-a-subsequence-using-cyclic-increments
3267-find-longest-special-substring-that-occurs-thrice-i
3309-count-prefix-and-suffix-pairs-i
3447-clear-digits
3455-minimum-length-of-string-after-operations
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Dynamic Programming

0005-longest-palindromic-substring
0494-target-sum
0689-maximum-sum-of-3-non-overlapping-subarrays
0905-length-of-longest-fibonacci-subsequence
1025-minimum-cost-for-tickets
1063-best-sightseeing-pair
1170-shortest-common-supersequence
1631-number-of-sub-arrays-with-odd-sum
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1849-maximum-absolute-sum-of-any-subarray
2164-two-best-non-overlapping-events
2262-solving-questions-with-brainpower
2562-count-ways-to-build-good-strings

Array

0001-two-sum
0015-3sum
0031-next-permutation
0075-sort-colors
0407-trapping-rain-water-ii
0494-target-sum
0689-maximum-sum-of-3-non-overlapping-subarrays
0780-max-chunks-to-make-sorted
0854-making-a-large-island
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1025-minimum-cost-for-tickets
1063-best-sightseeing-pair
1364-tuple-with-same-product
1396-count-servers-that-communicate
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1524-string-matching-in-an-array
1570-final-prices-with-a-special-discount-in-a-shop
1631-number-of-sub-arrays-with-odd-sum
1744-number-of-ways-to-form-a-target-string-given-a-dictionary
1819-construct-the-lexicographically-largest-valid-sequence
1849-maximum-absolute-sum-of-any-subarray
1876-map-of-highest-peak
1878-check-if-array-is-sorted-and-rotated
1886-minimum-limit-of-balls-in-a-bag
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1927-maximum-ascending-subarray-sum
2058-concatenation-of-array
2107-find-unique-binary-string
2145-grid-game
2164-two-best-non-overlapping-events
2262-solving-questions-with-brainpower
2265-partition-array-according-to-given-pivot
2292-counting-words-with-a-given-prefix
2358-number-of-ways-to-split-array
2448-count-number-of-bad-pairs
2465-shifting-letters-ii
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2478-longest-nice-subarray
2533-bitwise-xor-of-all-pairings
2551-apply-operations-to-an-array
2564-most-profitable-path-in-a-tree
2614-maximum-count-of-positive-integer-and-negative-integer
2640-maximum-number-of-integers-to-choose-from-a-range-i
2685-first-completely-painted-row-or-column
2690-house-robber-iv
2691-count-vowel-strings-in-ranges
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
2707-merge-two-2d-arrays-by-summing-values
2764-maximum-number-of-fish-in-a-grid
2766-find-the-prefix-common-array-of-two-arrays
2891-maximum-beauty-of-an-array-after-applying-operation
3181-find-building-where-alice-and-bob-can-meet
3219-make-lexicographically-smallest-array-by-swapping-elements
3227-find-missing-and-repeated-values
3309-count-prefix-and-suffix-pairs-i
3332-minimum-operations-to-exceed-threshold-value-ii
3372-longest-strictly-increasing-or-strictly-decreasing-subarray
3427-special-array-ii
3429-special-array-i
3434-find-the-number-of-distinct-colors-among-the-balls
3483-alternating-groups-ii
3555-final-array-state-after-k-multiplication-operations-i
3623-count-number-of-trapezoids-i
3643-zero-array-transformation-ii

Hash Table

0001-two-sum
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1364-tuple-with-same-product
1387-find-elements-in-a-contaminated-binary-tree
1460-number-of-substrings-containing-all-three-characters
1502-construct-k-palindrome-strings
1915-check-if-one-string-swap-can-make-strings-equal
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2300-construct-string-with-repeat-limit
2434-design-a-number-container-system
2448-count-number-of-bad-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2640-maximum-number-of-integers-to-choose-from-a-range-i
2685-first-completely-painted-row-or-column
2695-find-score-of-an-array-after-marking-all-elements
2707-merge-two-2d-arrays-by-summing-values
2766-find-the-prefix-common-array-of-two-arrays
3227-find-missing-and-repeated-values
3267-find-longest-special-substring-that-occurs-thrice-i
3434-find-the-number-of-distinct-colors-among-the-balls
3455-minimum-length-of-string-after-operations
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii
3623-count-number-of-trapezoids-i

Binary Search

1886-minimum-limit-of-balls-in-a-bag
2164-two-best-non-overlapping-events
2614-maximum-count-of-positive-integer-and-negative-integer
2640-maximum-number-of-integers-to-choose-from-a-range-i
2690-house-robber-iv
2891-maximum-beauty-of-an-array-after-applying-operation
3181-find-building-where-alice-and-bob-can-meet
3267-find-longest-special-substring-that-occurs-thrice-i
3427-special-array-ii
3643-zero-array-transformation-ii

Greedy

0780-max-chunks-to-make-sorted
1502-construct-k-palindrome-strings
2221-check-if-a-parentheses-string-can-be-valid
2300-construct-string-with-repeat-limit
2456-construct-smallest-number-from-di-string
2509-minimize-xor
2640-maximum-number-of-integers-to-choose-from-a-range-i

Sorting

0015-3sum
0075-sort-colors
0780-max-chunks-to-make-sorted
2164-two-best-non-overlapping-events
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2640-maximum-number-of-integers-to-choose-from-a-range-i
2695-find-score-of-an-array-after-marking-all-elements
2891-maximum-beauty-of-an-array-after-applying-operation
3219-make-lexicographically-smallest-array-by-swapping-elements

Heap (Priority Queue)

0407-trapping-rain-water-ii
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2164-two-best-non-overlapping-events
2300-construct-string-with-repeat-limit
2434-design-a-number-container-system
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
3181-find-building-where-alice-and-bob-can-meet
3332-minimum-operations-to-exceed-threshold-value-ii
3555-final-array-state-after-k-multiplication-operations-i

Prefix Sum

1537-maximum-score-after-splitting-a-string
1631-number-of-sub-arrays-with-odd-sum
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
2059-unique-length-3-palindromic-subsequences
2145-grid-game
2358-number-of-ways-to-split-array
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges
3427-special-array-ii
3643-zero-array-transformation-ii

Sliding Window

1460-number-of-substrings-containing-all-three-characters
2463-minimum-recolors-to-get-k-consecutive-black-blocks
2478-longest-nice-subarray
2891-maximum-beauty-of-an-array-after-applying-operation
3267-find-longest-special-substring-that-occurs-thrice-i
3483-alternating-groups-ii
3569-count-of-substrings-containing-every-vowel-and-k-consonants-ii

Counting

1364-tuple-with-same-product
1396-count-servers-that-communicate
1502-construct-k-palindrome-strings
1915-check-if-one-string-swap-can-make-strings-equal
2300-construct-string-with-repeat-limit
2448-count-number-of-bad-pairs
2614-maximum-count-of-positive-integer-and-negative-integer
3267-find-longest-special-substring-that-occurs-thrice-i
3455-minimum-length-of-string-after-operations

Simulation

2021-remove-all-occurrences-of-a-substring
2058-concatenation-of-array
2265-partition-array-according-to-given-pivot
2551-apply-operations-to-an-array
2692-take-gifts-from-the-richest-pile
2695-find-score-of-an-array-after-marking-all-elements
3332-minimum-operations-to-exceed-threshold-value-ii
3434-find-the-number-of-distinct-colors-among-the-balls
3447-clear-digits
3555-final-array-state-after-k-multiplication-operations-i

Math

1631-number-of-sub-arrays-with-odd-sum
1889-check-if-number-is-a-sum-of-powers-of-three
2448-count-number-of-bad-pairs
2649-count-total-number-of-colored-cells
2802-find-the-punishment-number-of-an-integer
3227-find-missing-and-repeated-values
3555-final-array-state-after-k-multiplication-operations-i
3623-count-number-of-trapezoids-i

Stack

0780-max-chunks-to-make-sorted
1570-final-prices-with-a-special-discount-in-a-shop
2021-remove-all-occurrences-of-a-substring
2221-check-if-a-parentheses-string-can-be-valid
2456-construct-smallest-number-from-di-string
3181-find-building-where-alice-and-bob-can-meet
3447-clear-digits

Monotonic Stack

0780-max-chunks-to-make-sorted
1570-final-prices-with-a-special-discount-in-a-shop
3181-find-building-where-alice-and-bob-can-meet

Tree

0515-find-largest-value-in-each-tree-row
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
2564-most-profitable-path-in-a-tree
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Depth-First Search

0515-find-largest-value-in-each-tree-row
0684-redundant-connection
0820-find-eventual-safe-states
0854-making-a-large-island
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
1396-count-servers-that-communicate
1558-course-schedule-iv
2246-maximum-employees-to-be-invited-to-a-meeting
2564-most-profitable-path-in-a-tree
2764-maximum-number-of-fish-in-a-grid
3058-maximum-number-of-k-divisible-components
3439-find-minimum-diameter-after-merging-two-trees

Binary Indexed Tree

3181-find-building-where-alice-and-bob-can-meet

Segment Tree

3181-find-building-where-alice-and-bob-can-meet

Breadth-First Search

0407-trapping-rain-water-ii
0515-find-largest-value-in-each-tree-row
0684-redundant-connection
0820-find-eventual-safe-states
0854-making-a-large-island
1387-find-elements-in-a-contaminated-binary-tree
1396-count-servers-that-communicate
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1558-course-schedule-iv
1876-map-of-highest-peak
2564-most-profitable-path-in-a-tree
2583-divide-nodes-into-the-maximum-number-of-groups
2764-maximum-number-of-fish-in-a-grid
3439-find-minimum-diameter-after-merging-two-trees

Graph

0684-redundant-connection
0820-find-eventual-safe-states
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1558-course-schedule-iv
2246-maximum-employees-to-be-invited-to-a-meeting
2564-most-profitable-path-in-a-tree
2583-divide-nodes-into-the-maximum-number-of-groups
3439-find-minimum-diameter-after-merging-two-trees

Binary Tree

0515-find-largest-value-in-each-tree-row
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1093-recover-a-tree-from-preorder-traversal
1387-find-elements-in-a-contaminated-binary-tree

Backtracking

0494-target-sum
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
1819-construct-the-lexicographically-largest-valid-sequence
2107-find-unique-binary-string
2456-construct-smallest-number-from-di-string
2802-find-the-punishment-number-of-an-integer

Bit Manipulation

2059-unique-length-3-palindromic-subsequences
2478-longest-nice-subarray
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2766-find-the-prefix-common-array-of-two-arrays

String Matching

1524-string-matching-in-an-array
2292-counting-words-with-a-given-prefix
3309-count-prefix-and-suffix-pairs-i

Trie

3309-count-prefix-and-suffix-pairs-i

Rolling Hash

3309-count-prefix-and-suffix-pairs-i

Hash Function

3309-count-prefix-and-suffix-pairs-i

Brainteaser

2533-bitwise-xor-of-all-pairings

Matrix

0407-trapping-rain-water-ii
0854-making-a-large-island
1396-count-servers-that-communicate
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1876-map-of-highest-peak
2145-grid-game
2685-first-completely-painted-row-or-column
2764-maximum-number-of-fish-in-a-grid
3227-find-missing-and-repeated-values

Shortest Path

1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid

Union Find

0684-redundant-connection
0854-making-a-large-island
1396-count-servers-that-communicate
2583-divide-nodes-into-the-maximum-number-of-groups
2764-maximum-number-of-fish-in-a-grid
3219-make-lexicographically-smallest-array-by-swapping-elements

Topological Sort

0820-find-eventual-safe-states
1558-course-schedule-iv
2246-maximum-employees-to-be-invited-to-a-meeting

Design

1387-find-elements-in-a-contaminated-binary-tree
2434-design-a-number-container-system

Ordered Set

2434-design-a-number-container-system

Divide and Conquer

0925-construct-binary-tree-from-preorder-and-postorder-traversal

Geometry

3623-count-number-of-trapezoids-i

About

Click Below To Redirect To Readme.md

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages