Skip to content

AnshPhirani/Leetcode-optimized-solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,816 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode-optimized-solutions

Collection of LeetCode questions to ace the coding interview!

LeetCode Topics

Math

0066-plus-one
0231-power-of-two
0326-power-of-three
0840-magic-squares-in-grid
1266-minimum-time-visiting-all-points
1390-four-divisors
1411-convert-binary-number-in-a-linked-list-to-integer
1529-max-difference-you-can-get-from-changing-an-integer
2202-sum-of-k-mirror-numbers
2661-smallest-missing-non-negative-integer-after-operations
2704-maximum-difference-by-remapping-a-digit
3047-find-the-largest-area-of-square-inside-two-rectangles
3201-distribute-candies-among-children-ii
3676-smallest-number-with-all-set-bits
3754-maximum-manhattan-distance-after-k-changes

Combinatorics

3201-distribute-candies-among-children-ii

Enumeration

2202-sum-of-k-mirror-numbers
2975-maximum-square-area-by-removing-fences-from-a-field
3201-distribute-candies-among-children-ii
3683-find-the-lexicographically-largest-string-from-the-box-i

Array

0036-valid-sudoku
0066-plus-one
0085-maximal-rectangle
0135-candy
0474-ones-and-zeroes
0594-longest-harmonious-subsequence
0840-magic-squares-in-grid
0944-delete-columns-to-make-sorted
1266-minimum-time-visiting-all-points
1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
1390-four-divisors
1424-maximum-candies-you-can-get-from-boxes
1458-max-dot-product-of-two-subsequences
1478-maximum-number-of-events-that-can-be-attended
1510-find-lucky-integer-in-an-array
1586-longest-subarray-of-1s-after-deleting-one-element
1710-maximum-units-on-a-truck
1813-maximum-erasure-value
1970-last-day-where-you-can-still-cross
1975-maximum-matrix-sum
2054-two-best-non-overlapping-events
2100-find-good-days-to-rob-the-bank
2137-final-value-of-variable-after-performing-operations
2204-find-subsequence-of-length-k-with-the-largest-sum
2320-find-all-k-distant-indices-in-an-array
2387-partition-array-such-that-maximum-difference-is-k
2402-meeting-rooms-iii
2497-maximum-matching-of-players-with-trainers
2529-range-product-queries-of-powers
2661-smallest-missing-non-negative-integer-after-operations
2720-minimize-the-maximum-difference-of-pairs
2943-maximize-area-of-square-hole-in-grid
2975-maximum-square-area-by-removing-fences-from-a-field
3047-find-the-largest-area-of-square-inside-two-rectangles
3074-apple-redistribution-into-boxes
3315-construct-the-minimum-bitwise-array-ii
3437-maximum-total-damage-with-spell-casting
3453-separate-squares-i
3454-separate-squares-ii
3461-find-the-minimum-area-to-cover-all-ones-i
3490-find-the-maximum-length-of-valid-subsequence-i
3501-delete-nodes-from-linked-list-present-in-array
3507-minimum-pair-removal-to-sort-array-i
3612-adjacent-increasing-subarrays-detection-i
3743-reschedule-meetings-for-maximum-free-time-i
3747-maximum-difference-between-adjacent-elements-in-a-circular-array

Greedy

0135-candy
1478-maximum-number-of-events-that-can-be-attended
1529-max-difference-you-can-get-from-changing-an-integer
1710-maximum-units-on-a-truck
1818-maximum-score-from-removing-substrings
1975-maximum-matrix-sum
2387-partition-array-such-that-maximum-difference-is-k
2395-longest-binary-subsequence-less-than-or-equal-to-k
2497-maximum-matching-of-players-with-trainers
2520-using-a-robot-to-print-the-lexicographically-smallest-string
2661-smallest-missing-non-negative-integer-after-operations
2704-maximum-difference-by-remapping-a-digit
2720-minimize-the-maximum-difference-of-pairs
3074-apple-redistribution-into-boxes
3445-lexicographically-minimum-string-after-removing-stars
3743-reschedule-meetings-for-maximum-free-time-i

Breadth-First Search

0865-smallest-subtree-with-all-the-deepest-nodes
1161-maximum-level-sum-of-a-binary-tree
1424-maximum-candies-you-can-get-from-boxes
1554-minimum-time-to-collect-all-apples-in-a-tree
1970-last-day-where-you-can-still-cross

Graph

1424-maximum-candies-you-can-get-from-boxes

Two Pointers

2320-find-all-k-distant-indices-in-an-array
2497-maximum-matching-of-players-with-trainers
3437-maximum-total-damage-with-spell-casting
3683-find-the-lexicographically-largest-string-from-the-box-i

String

0474-ones-and-zeroes
0712-minimum-ascii-delete-sum-for-two-strings
0756-pyramid-transition-matrix
0944-delete-columns-to-make-sorted
1058-lexicographically-smallest-equivalent-string
1818-maximum-score-from-removing-substrings
2137-final-value-of-variable-after-performing-operations
2222-number-of-ways-to-select-buildings
2260-divide-a-string-into-groups-of-size-k
2395-longest-binary-subsequence-less-than-or-equal-to-k
2483-minimum-penalty-for-a-shop
2520-using-a-robot-to-print-the-lexicographically-smallest-string
3396-valid-word
3445-lexicographically-minimum-string-after-removing-stars
3617-find-the-original-typed-string-i
3683-find-the-lexicographically-largest-string-from-the-box-i
3754-maximum-manhattan-distance-after-k-changes

Union Find

1058-lexicographically-smallest-equivalent-string
1970-last-day-where-you-can-still-cross

Hash Table

0036-valid-sudoku
0594-longest-harmonious-subsequence
0756-pyramid-transition-matrix
0840-magic-squares-in-grid
0865-smallest-subtree-with-all-the-deepest-nodes
1510-find-lucky-integer-in-an-array
1554-minimum-time-to-collect-all-apples-in-a-tree
1813-maximum-erasure-value
2204-find-subsequence-of-length-k-with-the-largest-sum
2402-meeting-rooms-iii
2520-using-a-robot-to-print-the-lexicographically-smallest-string
2661-smallest-missing-non-negative-integer-after-operations
2975-maximum-square-area-by-removing-fences-from-a-field
3437-maximum-total-damage-with-spell-casting
3445-lexicographically-minimum-string-after-removing-stars
3501-delete-nodes-from-linked-list-present-in-array
3507-minimum-pair-removal-to-sort-array-i
3754-maximum-manhattan-distance-after-k-changes

Stack

0085-maximal-rectangle
1818-maximum-score-from-removing-substrings
2520-using-a-robot-to-print-the-lexicographically-smallest-string
3445-lexicographically-minimum-string-after-removing-stars

Tree

0865-smallest-subtree-with-all-the-deepest-nodes
1161-maximum-level-sum-of-a-binary-tree
1339-maximum-product-of-splitted-binary-tree
1554-minimum-time-to-collect-all-apples-in-a-tree

Depth-First Search

0386-lexicographical-numbers
0865-smallest-subtree-with-all-the-deepest-nodes
1161-maximum-level-sum-of-a-binary-tree
1339-maximum-product-of-splitted-binary-tree
1554-minimum-time-to-collect-all-apples-in-a-tree
1970-last-day-where-you-can-still-cross

Heap (Priority Queue)

1478-maximum-number-of-events-that-can-be-attended
2054-two-best-non-overlapping-events
2204-find-subsequence-of-length-k-with-the-largest-sum
2402-meeting-rooms-iii
3445-lexicographically-minimum-string-after-removing-stars
3507-minimum-pair-removal-to-sort-array-i

Trie

0386-lexicographical-numbers
0440-k-th-smallest-in-lexicographical-order

Binary Search

1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
1970-last-day-where-you-can-still-cross
2054-two-best-non-overlapping-events
2720-minimize-the-maximum-difference-of-pairs
3437-maximum-total-damage-with-spell-casting
3453-separate-squares-i
3454-separate-squares-ii

Sorting

0594-longest-harmonious-subsequence
1478-maximum-number-of-events-that-can-be-attended
1710-maximum-units-on-a-truck
2054-two-best-non-overlapping-events
2204-find-subsequence-of-length-k-with-the-largest-sum
2387-partition-array-such-that-maximum-difference-is-k
2402-meeting-rooms-iii
2497-maximum-matching-of-players-with-trainers
2943-maximize-area-of-square-hole-in-grid
3074-apple-redistribution-into-boxes
3437-maximum-total-damage-with-spell-casting

Counting

0594-longest-harmonious-subsequence
1510-find-lucky-integer-in-an-array
3437-maximum-total-damage-with-spell-casting
3754-maximum-manhattan-distance-after-k-changes

Simulation

2137-final-value-of-variable-after-performing-operations
2260-divide-a-string-into-groups-of-size-k
2402-meeting-rooms-iii
3507-minimum-pair-removal-to-sort-array-i

Dynamic Programming

0085-maximal-rectangle
0474-ones-and-zeroes
0712-minimum-ascii-delete-sum-for-two-strings
1411-number-of-ways-to-paint-n-3-grid
1458-max-dot-product-of-two-subsequences
1586-longest-subarray-of-1s-after-deleting-one-element
2054-two-best-non-overlapping-events
2100-find-good-days-to-rob-the-bank
2222-number-of-ways-to-select-buildings
2395-longest-binary-subsequence-less-than-or-equal-to-k
3437-maximum-total-damage-with-spell-casting
3490-find-the-maximum-length-of-valid-subsequence-i

Memoization

2395-longest-binary-subsequence-less-than-or-equal-to-k

Sliding Window

0594-longest-harmonious-subsequence
1586-longest-subarray-of-1s-after-deleting-one-element
1813-maximum-erasure-value
3743-reschedule-meetings-for-maximum-free-time-i

Linked List

1411-convert-binary-number-in-a-linked-list-to-integer
3501-delete-nodes-from-linked-list-present-in-array
3507-minimum-pair-removal-to-sort-array-i

Bit Manipulation

0231-power-of-two
0756-pyramid-transition-matrix
2529-range-product-queries-of-powers
3315-construct-the-minimum-bitwise-array-ii
3676-smallest-number-with-all-set-bits

Recursion

0231-power-of-two
0326-power-of-three

Prefix Sum

1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
2100-find-good-days-to-rob-the-bank
2222-number-of-ways-to-select-buildings
2483-minimum-penalty-for-a-shop
2529-range-product-queries-of-powers

Matrix

0036-valid-sudoku
0085-maximal-rectangle
0840-magic-squares-in-grid
1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
1970-last-day-where-you-can-still-cross
1975-maximum-matrix-sum
3461-find-the-minimum-area-to-cover-all-ones-i

Backtracking

0756-pyramid-transition-matrix

Binary Tree

0865-smallest-subtree-with-all-the-deepest-nodes
1161-maximum-level-sum-of-a-binary-tree
1339-maximum-product-of-splitted-binary-tree

Monotonic Stack

0085-maximal-rectangle

Geometry

1266-minimum-time-visiting-all-points
3047-find-the-largest-area-of-square-inside-two-rectangles

Segment Tree

3454-separate-squares-ii

Line Sweep

3454-separate-squares-ii

Doubly-Linked List

3507-minimum-pair-removal-to-sort-array-i

Ordered Set

3507-minimum-pair-removal-to-sort-array-i

About

Collection of LeetCode questions to ace the coding interview!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors