Skip to content
SathvikBhaskarPublic

About

LeetCode solutions in C++ and SQL - a practice log covering arrays, dynamic programming, graphs and trees.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

850 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode

My LeetCode practice log - C++ and SQL solutions covering arrays, dynamic programming, graphs and trees.

LeetCode Topics

Divide and Conquer

0053-maximum-subarray
0191-number-of-1-bits
0347-top-k-frequent-elements

Bit Manipulation

0078-subsets
0137-single-number-ii
0191-number-of-1-bits
0231-power-of-two
0260-single-number-iii
2220-minimum-bit-flips-to-convert-number
3370-smallest-number-with-all-set-bits
3750-minimum-number-of-flips-to-reverse-binary-string

Array

0011-container-with-most-water
0014-longest-common-prefix
0015-3sum
0018-4sum
0031-next-permutation
0042-trapping-rain-water
0048-rotate-image
0049-group-anagrams
0053-maximum-subarray
0063-unique-paths-ii
0064-minimum-path-sum
0073-set-matrix-zeroes
0078-subsets
0120-triangle
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0137-single-number-ii
0167-two-sum-ii-input-array-is-sorted
0189-rotate-array
0198-house-robber
0204-count-primes
0217-contains-duplicate
0238-product-of-array-except-self
0260-single-number-iii
0322-coin-change
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
0368-largest-divisible-subset
0416-partition-equal-subset-sum
0494-target-sum
0496-next-greater-element-i
0503-next-greater-element-ii
0518-coin-change-ii
0673-number-of-longest-increasing-subsequence
0717-1-bit-and-2-bit-characters
0746-min-cost-climbing-stairs
0747-largest-number-at-least-twice-of-others
0792-binary-search
0835-image-overlap
0875-koko-eating-bananas
0877-stone-game
0904-fruit-into-baskets
0905-sort-array-by-parity
0931-minimum-falling-path-sum
1004-max-consecutive-ones-iii
1351-count-negative-numbers-in-a-sorted-matrix
1423-maximum-points-you-can-obtain-from-cards
1437-check-if-all-1s-are-at-least-length-k-places-away
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1512-number-of-good-pairs
1671-minimum-number-of-removals-to-make-mountain-array
1752-check-if-array-is-sorted-and-rotated
1769-minimum-number-of-operations-to-move-all-balls-to-each-box
1838-frequency-of-the-most-frequent-element
1920-build-array-from-permutation
1929-concatenation-of-array
2011-final-value-of-variable-after-performing-operations
2091-removing-minimum-and-maximum-from-array
2161-partition-array-according-to-given-pivot
2373-largest-local-values-in-a-matrix
2410-maximum-matching-of-players-with-trainers
2574-left-and-right-sum-differences
2798-number-of-employees-who-met-the-target
2942-find-words-containing-character
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3069-distribute-elements-into-two-arrays-i
3190-find-minimum-operations-to-make-all-elements-divisible-by-three
3194-minimum-average-of-smallest-and-largest-elements
3264-final-array-state-after-k-multiplication-operations-i
3289-the-two-sneaky-numbers-of-digitville
3414-maximum-score-of-non-overlapping-intervals
3483-unique-3-digit-even-numbers
3512-minimum-operations-to-make-array-sum-divisible-by-k
3550-smallest-index-with-digit-sum-equal-to-index
3643-flip-square-submatrix-vertically
3668-restore-finishing-order
3689-maximum-total-subarray-value-i
3701-compute-alternating-sum
3875-construct-uniform-parity-array-i
3876-construct-uniform-parity-array-ii
3898-find-the-degree-of-each-vertex
3903-smallest-stable-index-i
3904-smallest-stable-index-ii
3925-concatenate-array-with-reverse

Binary Search

0167-two-sum-ii-input-array-is-sorted
0349-intersection-of-two-arrays
0792-binary-search
0875-koko-eating-bananas
1004-max-consecutive-ones-iii
1351-count-negative-numbers-in-a-sorted-matrix
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1671-minimum-number-of-removals-to-make-mountain-array
1838-frequency-of-the-most-frequent-element
3414-maximum-score-of-non-overlapping-intervals

Math

0007-reverse-integer
0009-palindrome-number
0013-roman-to-integer
0048-rotate-image
0050-powx-n
0062-unique-paths
0189-rotate-array
0204-count-primes
0231-power-of-two
0258-add-digits
0368-largest-divisible-subset
0509-fibonacci-number
0836-rectangle-overlap
0877-stone-game
1512-number-of-good-pairs
1523-count-odd-numbers-in-an-interval-range
1621-number-of-sets-of-k-non-overlapping-line-segments
1688-count-of-matches-in-tournament
1716-calculate-money-in-leetcode-bank
1903-largest-odd-number-in-string
1922-count-good-numbers
2169-count-operations-to-obtain-zero
2235-add-two-integers
2520-count-the-digits-that-divide-a-number
2652-sum-multiples
3190-find-minimum-operations-to-make-all-elements-divisible-by-three
3264-final-array-state-after-k-multiplication-operations-i
3289-the-two-sneaky-numbers-of-digitville
3345-smallest-divisible-digit-product-i
3370-smallest-number-with-all-set-bits
3512-minimum-operations-to-make-array-sum-divisible-by-k
3516-find-closest-person
3550-smallest-index-with-digit-sum-equal-to-index
3750-minimum-number-of-flips-to-reverse-binary-string
3783-mirror-distance-of-an-integer
3870-count-commas-in-range
3871-count-commas-in-range-ii
3875-construct-uniform-parity-array-i
3876-construct-uniform-parity-array-ii
3945-digit-frequency-score

Simulation

0258-add-digits
1688-count-of-matches-in-tournament
1920-build-array-from-permutation
1929-concatenation-of-array
2011-final-value-of-variable-after-performing-operations
2161-partition-array-according-to-given-pivot
2169-count-operations-to-obtain-zero
3069-distribute-elements-into-two-arrays-i
3264-final-array-state-after-k-multiplication-operations-i
3498-reverse-degree-of-a-string
3701-compute-alternating-sum
3925-concatenate-array-with-reverse

Number Theory

0204-count-primes
0258-add-digits

Sorting

0015-3sum
0018-4sum
0049-group-anagrams
0217-contains-duplicate
0242-valid-anagram
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
0368-largest-divisible-subset
0747-largest-number-at-least-twice-of-others
0905-sort-array-by-parity
0987-vertical-order-traversal-of-a-binary-tree
1838-frequency-of-the-most-frequent-element
2410-maximum-matching-of-players-with-trainers
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3194-minimum-average-of-smallest-and-largest-elements
3414-maximum-score-of-non-overlapping-intervals

Hash Table

0003-longest-substring-without-repeating-characters
0013-roman-to-integer
0049-group-anagrams
0073-set-matrix-zeroes
0128-longest-consecutive-sequence
0141-linked-list-cycle
0142-linked-list-cycle-ii
0205-isomorphic-strings
0217-contains-duplicate
0242-valid-anagram
0347-top-k-frequent-elements
0349-intersection-of-two-arrays
0424-longest-repeating-character-replacement
0496-next-greater-element-i
0567-permutation-in-string
0904-fruit-into-baskets
0987-vertical-order-traversal-of-a-binary-tree
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1512-number-of-good-pairs
2996-smallest-missing-integer-greater-than-sequential-prefix-sum
3289-the-two-sneaky-numbers-of-digitville
3483-unique-3-digit-even-numbers
3668-restore-finishing-order
3760-maximum-substrings-with-distinct-start
3945-digit-frequency-score

String

0003-longest-substring-without-repeating-characters
0008-string-to-integer-atoi
0013-roman-to-integer
0014-longest-common-prefix
0020-valid-parentheses
0022-generate-parentheses
0044-wildcard-matching
0049-group-anagrams
0072-edit-distance
0115-distinct-subsequences
0125-valid-palindrome
0151-reverse-words-in-a-string
0205-isomorphic-strings
0242-valid-anagram
0257-binary-tree-paths
0344-reverse-string
0424-longest-repeating-character-replacement
0516-longest-palindromic-subsequence
0557-reverse-words-in-a-string-iii
0567-permutation-in-string
0583-delete-operation-for-two-strings
0678-valid-parenthesis-string
0709-to-lower-case
0856-score-of-parentheses
0921-minimum-add-to-make-parentheses-valid
0940-distinct-subsequences-ii
1021-remove-outermost-parentheses
1047-remove-all-adjacent-duplicates-in-string
1092-shortest-common-supersequence
1108-defanging-an-ip-address
1143-longest-common-subsequence
1221-split-a-string-in-balanced-strings
1312-minimum-insertion-steps-to-make-a-string-palindrome
1689-partitioning-into-minimum-number-of-deci-binary-numbers
1769-minimum-number-of-operations-to-move-all-balls-to-each-box
1903-largest-odd-number-in-string
1963-minimum-number-of-swaps-to-make-the-string-balanced
2011-final-value-of-variable-after-performing-operations
2472-maximum-number-of-non-overlapping-palindrome-substrings
2697-lexicographically-smallest-palindrome
2942-find-words-containing-character
3498-reverse-degree-of-a-string
3750-minimum-number-of-flips-to-reverse-binary-string
3760-maximum-substrings-with-distinct-start
3884-first-matching-character-from-both-ends

Sliding Window

0003-longest-substring-without-repeating-characters
0424-longest-repeating-character-replacement
0567-permutation-in-string
0904-fruit-into-baskets
1004-max-consecutive-ones-iii
1423-maximum-points-you-can-obtain-from-cards
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1838-frequency-of-the-most-frequent-element

Two Pointers

0011-container-with-most-water
0015-3sum
0018-4sum
0031-next-permutation
0042-trapping-rain-water
0125-valid-palindrome
0141-linked-list-cycle
0142-linked-list-cycle-ii
0151-reverse-words-in-a-string
0167-two-sum-ii-input-array-is-sorted
0189-rotate-array
0234-palindrome-linked-list
0344-reverse-string
0349-intersection-of-two-arrays
0557-reverse-words-in-a-string-iii
0567-permutation-in-string
0876-middle-of-the-linked-list
0905-sort-array-by-parity
1963-minimum-number-of-swaps-to-make-the-string-balanced
2161-partition-array-according-to-given-pivot
2410-maximum-matching-of-players-with-trainers
2472-maximum-number-of-non-overlapping-palindrome-substrings
2697-lexicographically-smallest-palindrome
3069-distribute-elements-into-two-arrays-i
3194-minimum-average-of-smallest-and-largest-elements
3643-flip-square-submatrix-vertically
3750-minimum-number-of-flips-to-reverse-binary-string
3884-first-matching-character-from-both-ends

Stack

0020-valid-parentheses
0042-trapping-rain-water
0094-binary-tree-inorder-traversal
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0155-min-stack
0225-implement-stack-using-queues
0232-implement-queue-using-stacks
0234-palindrome-linked-list
0496-next-greater-element-i
0503-next-greater-element-ii
0678-valid-parenthesis-string
0856-score-of-parentheses
0921-minimum-add-to-make-parentheses-valid
1021-remove-outermost-parentheses
1047-remove-all-adjacent-duplicates-in-string
1963-minimum-number-of-swaps-to-make-the-string-balanced

Dynamic Programming

0022-generate-parentheses
0042-trapping-rain-water
0044-wildcard-matching
0053-maximum-subarray
0062-unique-paths
0063-unique-paths-ii
0064-minimum-path-sum
0072-edit-distance
0115-distinct-subsequences
0120-triangle
0121-best-time-to-buy-and-sell-stock
0124-binary-tree-maximum-path-sum
0198-house-robber
0322-coin-change
0368-largest-divisible-subset
0416-partition-equal-subset-sum
0494-target-sum
0509-fibonacci-number
0516-longest-palindromic-subsequence
0518-coin-change-ii
0583-delete-operation-for-two-strings
0673-number-of-longest-increasing-subsequence
0678-valid-parenthesis-string
0746-min-cost-climbing-stairs
0877-stone-game
0931-minimum-falling-path-sum
0940-distinct-subsequences-ii
1092-shortest-common-supersequence
1143-longest-common-subsequence
1312-minimum-insertion-steps-to-make-a-string-palindrome
1477-find-two-non-overlapping-sub-arrays-each-with-target-sum
1621-number-of-sets-of-k-non-overlapping-line-segments
1671-minimum-number-of-removals-to-make-mountain-array
2472-maximum-number-of-non-overlapping-palindrome-substrings
3414-maximum-score-of-non-overlapping-intervals

Recursion

0044-wildcard-matching
0050-powx-n
0206-reverse-linked-list
0231-power-of-two
0234-palindrome-linked-list
0509-fibonacci-number
1922-count-good-numbers
3483-unique-3-digit-even-numbers

Memoization

0509-fibonacci-number

Greedy

0011-container-with-most-water
0044-wildcard-matching
0678-valid-parenthesis-string
0921-minimum-add-to-make-parentheses-valid
1221-split-a-string-in-balanced-strings
1671-minimum-number-of-removals-to-make-mountain-array
1689-partitioning-into-minimum-number-of-deci-binary-numbers
1838-frequency-of-the-most-frequent-element
1903-largest-odd-number-in-string
1963-minimum-number-of-swaps-to-make-the-string-balanced
2091-removing-minimum-and-maximum-from-array
2410-maximum-matching-of-players-with-trainers
2472-maximum-number-of-non-overlapping-palindrome-substrings
2697-lexicographically-smallest-palindrome
3689-maximum-total-subarray-value-i

Prefix Sum

0238-product-of-array-except-self
1004-max-consecutive-ones-iii
1423-maximum-points-you-can-obtain-from-cards
1621-number-of-sets-of-k-non-overlapping-line-segments
1769-minimum-number-of-operations-to-move-all-balls-to-each-box
1838-frequency-of-the-most-frequent-element
2574-left-and-right-sum-differences
3903-smallest-stable-index-i
3904-smallest-stable-index-ii

Matrix

0048-rotate-image
0063-unique-paths-ii
0064-minimum-path-sum
0073-set-matrix-zeroes
0835-image-overlap
0931-minimum-falling-path-sum
1351-count-negative-numbers-in-a-sorted-matrix
2373-largest-local-values-in-a-matrix
3643-flip-square-submatrix-vertically
3898-find-the-degree-of-each-vertex

Counting

0347-top-k-frequent-elements
1221-split-a-string-in-balanced-strings
1512-number-of-good-pairs

Heap (Priority Queue)

0347-top-k-frequent-elements
3264-final-array-state-after-k-multiplication-operations-i

Trie

0014-longest-common-prefix

Linked List

0141-linked-list-cycle
0142-linked-list-cycle-ii
0206-reverse-linked-list
0234-palindrome-linked-list
0237-delete-node-in-a-linked-list
0876-middle-of-the-linked-list

Design

0155-min-stack
0225-implement-stack-using-queues
0232-implement-queue-using-stacks

Queue

0225-implement-stack-using-queues
0232-implement-queue-using-stacks

Monotonic Stack

0042-trapping-rain-water
0496-next-greater-element-i
0503-next-greater-element-ii

Backtracking

0022-generate-parentheses
0078-subsets
0113-path-sum-ii
0257-binary-tree-paths
0494-target-sum

Bucket Sort

0347-top-k-frequent-elements

Quickselect

0347-top-k-frequent-elements

Union-Find

0128-longest-consecutive-sequence
0547-number-of-provinces

Depth-First Search

0094-binary-tree-inorder-traversal
0100-same-tree
0101-symmetric-tree
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0199-binary-tree-right-side-view
0236-lowest-common-ancestor-of-a-binary-tree
0257-binary-tree-paths
0543-diameter-of-binary-tree
0547-number-of-provinces
0637-average-of-levels-in-binary-tree
0662-maximum-width-of-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
2265-count-nodes-equal-to-average-of-subtree

Breadth-First Search

0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0107-binary-tree-level-order-traversal-ii
0112-path-sum
0199-binary-tree-right-side-view
0322-coin-change
0547-number-of-provinces
0637-average-of-levels-in-binary-tree
0662-maximum-width-of-binary-tree
0987-vertical-order-traversal-of-a-binary-tree

Graph Theory

0547-number-of-provinces
3898-find-the-degree-of-each-vertex

Combinatorics

0062-unique-paths
1621-number-of-sets-of-k-non-overlapping-line-segments

Game Theory

0877-stone-game

Knapsack Problem

0494-target-sum

0-1 Knapsack

0494-target-sum

Enumeration

0204-count-primes
3345-smallest-divisible-digit-product-i
3483-unique-3-digit-even-numbers

Longest Common Subsequence

0583-delete-operation-for-two-strings
1092-shortest-common-supersequence
1143-longest-common-subsequence

Primality Test

0204-count-primes

Sieve Theory

0204-count-primes

Prime Number Sieve

0204-count-primes

Database

0175-combine-two-tables
0181-employees-earning-more-than-their-managers
0182-duplicate-emails
0196-delete-duplicate-emails
0570-managers-with-at-least-5-direct-reports
0577-employee-bonus
0584-find-customer-referee
0586-customer-placing-the-largest-number-of-orders
0595-big-countries
0596-classes-with-at-least-5-students
0620-not-boring-movies
1050-actors-and-directors-who-cooperated-at-least-three-times
1068-product-sales-analysis-i
1148-article-views-i
1378-replace-employee-id-with-the-unique-identifier
1527-patients-with-a-condition
1683-invalid-tweets
1729-find-followers-count
1757-recyclable-and-low-fat-products
2356-number-of-unique-subjects-taught-by-each-teacher

Binary Indexed Tree

0673-number-of-longest-increasing-subsequence

Segment Tree

0673-number-of-longest-increasing-subsequence

Longest Increasing Subsequence

0673-number-of-longest-increasing-subsequence

Tree

0094-binary-tree-inorder-traversal
0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0107-binary-tree-level-order-traversal-ii
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0199-binary-tree-right-side-view
0236-lowest-common-ancestor-of-a-binary-tree
0257-binary-tree-paths
0543-diameter-of-binary-tree
0637-average-of-levels-in-binary-tree
0662-maximum-width-of-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
2265-count-nodes-equal-to-average-of-subtree

Binary Tree

0094-binary-tree-inorder-traversal
0100-same-tree
0101-symmetric-tree
0102-binary-tree-level-order-traversal
0103-binary-tree-zigzag-level-order-traversal
0104-maximum-depth-of-binary-tree
0107-binary-tree-level-order-traversal-ii
0110-balanced-binary-tree
0112-path-sum
0113-path-sum-ii
0124-binary-tree-maximum-path-sum
0144-binary-tree-preorder-traversal
0145-binary-tree-postorder-traversal
0199-binary-tree-right-side-view
0236-lowest-common-ancestor-of-a-binary-tree
0257-binary-tree-paths
0543-diameter-of-binary-tree
0637-average-of-levels-in-binary-tree
0662-maximum-width-of-binary-tree
0987-vertical-order-traversal-of-a-binary-tree
2265-count-nodes-equal-to-average-of-subtree

DP on Trees

0124-binary-tree-maximum-path-sum
0543-diameter-of-binary-tree

Binary Lifting

0236-lowest-common-ancestor-of-a-binary-tree

Lowest Common Ancestor

0236-lowest-common-ancestor-of-a-binary-tree

Geometry

0836-rectangle-overlap

Bracket Sequences

0020-valid-parentheses
0022-generate-parentheses
0678-valid-parenthesis-string
0856-score-of-parentheses
0921-minimum-add-to-make-parentheses-valid
1021-remove-outermost-parentheses
1963-minimum-number-of-swaps-to-make-the-string-balanced

About

LeetCode solutions in C++ and SQL - a practice log covering arrays, dynamic programming, graphs and trees.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages