Skip to content

1511Darshan/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions by Darshan

Welcome to my LeetCode solutions repository! This repo contains my solutions to various algorithm and data structure problems from LeetCode, implemented mainly in C++.
The goal of this repo is to track my problem-solving progress, improve my coding skills, and share helpful solutions with the community.


About

This repository is a personal collection of solutions to LeetCode problems. Each solution aims to provide clear, optimized, and well-commented code for better understanding.
I update this repo regularly as I solve new problems and revise older ones.


LeetCode Topics

Linked List

0002-add-two-numbers
1267-remove-zero-sum-consecutive-nodes-from-linked-list
2903-insert-greatest-common-divisors-in-linked-list
3501-delete-nodes-from-linked-list-present-in-array

Math

0002-add-two-numbers
0043-multiply-strings
0231-power-of-two
0268-missing-number
0670-maximum-swap
0900-reordered-power-of-2
1018-largest-perimeter-triangle
1426-find-n-unique-integers-sum-up-to-zero
1635-number-of-good-pairs
1642-water-bottles
1889-check-if-number-is-a-sum-of-powers-of-three
2610-closest-prime-numbers-in-range
2649-count-total-number-of-colored-cells
2903-insert-greatest-common-divisors-in-linked-list
3172-divisible-and-non-divisible-sums-difference
3201-distribute-candies-among-children-ii
3227-find-missing-and-repeated-values
3321-type-of-triangle
3336-water-bottles-ii
3515-find-if-digit-game-can-be-won
3581-the-two-sneaky-numbers-of-digitville
3676-smallest-number-with-all-set-bits
3768-check-if-digits-are-equal-in-string-after-operations-i

Recursion

0002-add-two-numbers
0231-power-of-two
1197-parsing-a-boolean-expression
1667-find-kth-bit-in-nth-binary-string

Array

0001-two-sum
0026-remove-duplicates-from-sorted-array
0036-valid-sudoku
0037-sudoku-solver
0041-first-missing-positive
0075-sort-colors
0120-triangle
0121-best-time-to-buy-and-sell-stock
0135-candy
0136-single-number
0167-two-sum-ii-input-array-is-sorted
0169-majority-element
0217-contains-duplicate
0219-contains-duplicate-ii
0268-missing-number
0283-move-zeroes
0287-find-the-duplicate-number
0347-top-k-frequent-elements
0448-find-all-numbers-disappeared-in-an-array
0455-assign-cookies
0611-valid-triangle-number
0645-set-mismatch
0745-find-smallest-letter-greater-than-target
0833-bus-routes
0934-bitwise-ors-of-subarrays
1002-maximum-width-ramp
1018-largest-perimeter-triangle
1249-snapshot-array
1293-three-consecutive-odds
1335-maximum-candies-allocated-to-k-children
1402-count-square-submatrices-with-all-ones
1407-group-the-people-given-the-group-size-they-belong-to
1424-maximum-candies-you-can-get-from-boxes
1426-find-n-unique-integers-sum-up-to-zero
1586-longest-subarray-of-1s-after-deleting-one-element
1635-number-of-good-pairs
1760-check-array-formation-through-concatenation
1834-minimum-number-of-people-to-teach
2023-design-movie-rental-system
2137-final-value-of-variable-after-performing-operations
2170-count-number-of-maximum-bitwise-or-subsets
2265-partition-array-according-to-given-pivot
2308-divide-array-into-equal-pairs
2316-count-hills-and-valleys-in-an-array
2343-count-unguarded-cells-in-the-grid
2478-longest-nice-subarray
2483-task-scheduler-ii
2498-smallest-subarrays-with-maximum-bitwise-or
2503-longest-subarray-with-maximum-bitwise-and
2529-range-product-queries-of-powers
2614-maximum-count-of-positive-integer-and-negative-integer
2689-rearranging-fruits
2707-merge-two-2d-arrays-by-summing-values
2724-convert-an-array-into-a-2d-array-with-conditions
2755-extra-characters-in-a-string
2766-find-the-prefix-common-array-of-two-arrays
2888-minimum-index-of-a-valid-split
3194-find-words-containing-character
3227-find-missing-and-repeated-values
3321-type-of-triangle
3430-count-days-without-meetings
3459-find-the-minimum-area-to-cover-all-ones-ii
3461-find-the-minimum-area-to-cover-all-ones-i
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3501-delete-nodes-from-linked-list-present-in-array
3515-find-if-digit-game-can-be-won
3581-the-two-sneaky-numbers-of-digitville
3610-find-x-sum-of-all-k-long-subarrays-i
3648-find-the-maximum-number-of-fruits-collected
3789-maximize-subarrays-after-removing-one-conflicting-pair
3819-count-covered-buildings
3827-implement-router
3863-power-grid-maintenance

Hash Table

0001-two-sum
0036-valid-sudoku
0037-sudoku-solver
0041-first-missing-positive
0169-majority-element
0217-contains-duplicate
0219-contains-duplicate-ii
0242-valid-anagram
0268-missing-number
0347-top-k-frequent-elements
0448-find-all-numbers-disappeared-in-an-array
0645-set-mismatch
0833-bus-routes
0900-reordered-power-of-2
0920-uncommon-words-from-two-sentences
1218-lowest-common-ancestor-of-deepest-leaves
1249-snapshot-array
1267-remove-zero-sum-consecutive-nodes-from-linked-list
1407-group-the-people-given-the-group-size-they-belong-to
1460-number-of-substrings-containing-all-three-characters
1635-number-of-good-pairs
1760-check-array-formation-through-concatenation
1777-determine-if-two-strings-are-close
1834-minimum-number-of-people-to-teach
2023-design-movie-rental-system
2308-divide-array-into-equal-pairs
2483-task-scheduler-ii
2689-rearranging-fruits
2707-merge-two-2d-arrays-by-summing-values
2724-convert-an-array-into-a-2d-array-with-conditions
2755-extra-characters-in-a-string
2766-find-the-prefix-common-array-of-two-arrays
2888-minimum-index-of-a-valid-split
3227-find-missing-and-repeated-values
3501-delete-nodes-from-linked-list-present-in-array
3581-the-two-sneaky-numbers-of-digitville
3610-find-x-sum-of-all-k-long-subarrays-i
3819-count-covered-buildings
3827-implement-router
3863-power-grid-maintenance

Two Pointers

0026-remove-duplicates-from-sorted-array
0075-sort-colors
0167-two-sum-ii-input-array-is-sorted
0283-move-zeroes
0287-find-the-duplicate-number
0455-assign-cookies
0611-valid-triangle-number
0680-valid-palindrome-ii
1002-maximum-width-ramp
2128-reverse-prefix-of-word
2265-partition-array-according-to-given-pivot
2707-merge-two-2d-arrays-by-summing-values
3683-find-the-lexicographically-largest-string-from-the-box-i

Number Theory

2610-closest-prime-numbers-in-range
2903-insert-greatest-common-divisors-in-linked-list
3768-check-if-digits-are-equal-in-string-after-operations-i

String

0008-string-to-integer-atoi
0043-multiply-strings
0242-valid-anagram
0680-valid-palindrome-ii
0812-rotate-string
0920-uncommon-words-from-two-sentences
1058-lexicographically-smallest-equivalent-string
1197-parsing-a-boolean-expression
1205-defanging-an-ip-address
1304-longest-happy-string
1460-number-of-substrings-containing-all-three-characters
1667-find-kth-bit-in-nth-binary-string
1777-determine-if-two-strings-are-close
2128-reverse-prefix-of-word
2137-final-value-of-variable-after-performing-operations
2755-extra-characters-in-a-string
3194-find-words-containing-character
3312-number-of-changing-keys
3379-score-of-a-string
3683-find-the-lexicographically-largest-string-from-the-box-i
3768-check-if-digits-are-equal-in-string-after-operations-i

Simulation

0043-multiply-strings
1642-water-bottles
1667-find-kth-bit-in-nth-binary-string
2137-final-value-of-variable-after-performing-operations
2265-partition-array-according-to-given-pivot
2343-count-unguarded-cells-in-the-grid
2408-number-of-people-aware-of-a-secret
2483-task-scheduler-ii
3336-water-bottles-ii
3768-check-if-digits-are-equal-in-string-after-operations-i

Combinatorics

3201-distribute-candies-among-children-ii
3768-check-if-digits-are-equal-in-string-after-operations-i

Backtracking

0037-sudoku-solver
2170-count-number-of-maximum-bitwise-or-subsets

Bit Manipulation

0136-single-number
0231-power-of-two
0268-missing-number
0287-find-the-duplicate-number
0645-set-mismatch
0934-bitwise-ors-of-subarrays
2170-count-number-of-maximum-bitwise-or-subsets
2308-divide-array-into-equal-pairs
2478-longest-nice-subarray
2498-smallest-subarrays-with-maximum-bitwise-or
2503-longest-subarray-with-maximum-bitwise-and
2529-range-product-queries-of-powers
2766-find-the-prefix-common-array-of-two-arrays
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3676-smallest-number-with-all-set-bits

Enumeration

0900-reordered-power-of-2
2170-count-number-of-maximum-bitwise-or-subsets
3201-distribute-candies-among-children-ii
3459-find-the-minimum-area-to-cover-all-ones-ii
3683-find-the-lexicographically-largest-string-from-the-box-i
3789-maximize-subarrays-after-removing-one-conflicting-pair

Greedy

0135-candy
0455-assign-cookies
0611-valid-triangle-number
0670-maximum-swap
0680-valid-palindrome-ii
1018-largest-perimeter-triangle
1304-longest-happy-string
1407-group-the-people-given-the-group-size-they-belong-to
1834-minimum-number-of-people-to-teach
2689-rearranging-fruits

Counting

0169-majority-element
0347-top-k-frequent-elements
0900-reordered-power-of-2
0920-uncommon-words-from-two-sentences
1635-number-of-good-pairs
1777-determine-if-two-strings-are-close
2308-divide-array-into-equal-pairs
2614-maximum-count-of-positive-integer-and-negative-integer

Matrix

0036-valid-sudoku
0037-sudoku-solver
1402-count-square-submatrices-with-all-ones
2343-count-unguarded-cells-in-the-grid
3227-find-missing-and-repeated-values
3459-find-the-minimum-area-to-cover-all-ones-ii
3461-find-the-minimum-area-to-cover-all-ones-i
3648-find-the-maximum-number-of-fruits-collected

Binary Search

0167-two-sum-ii-input-array-is-sorted
0268-missing-number
0278-first-bad-version
0287-find-the-duplicate-number
0611-valid-triangle-number
0745-find-smallest-letter-greater-than-target
1249-snapshot-array
1335-maximum-candies-allocated-to-k-children
2498-smallest-subarrays-with-maximum-bitwise-or
2614-maximum-count-of-positive-integer-and-negative-integer
3827-implement-router

Sorting

0075-sort-colors
0169-majority-element
0217-contains-duplicate
0242-valid-anagram
0268-missing-number
0347-top-k-frequent-elements
0455-assign-cookies
0611-valid-triangle-number
0645-set-mismatch
0900-reordered-power-of-2
1018-largest-perimeter-triangle
1777-determine-if-two-strings-are-close
2689-rearranging-fruits
2888-minimum-index-of-a-valid-split
3321-type-of-triangle
3430-count-days-without-meetings
3819-count-covered-buildings

Stack

1002-maximum-width-ramp
1197-parsing-a-boolean-expression
2128-reverse-prefix-of-word

Monotonic Stack

1002-maximum-width-ramp

Sliding Window

0219-contains-duplicate-ii
1460-number-of-substrings-containing-all-three-characters
1586-longest-subarray-of-1s-after-deleting-one-element
2478-longest-nice-subarray
2498-smallest-subarrays-with-maximum-bitwise-or
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3610-find-x-sum-of-all-k-long-subarrays-i

Heap (Priority Queue)

0347-top-k-frequent-elements
1304-longest-happy-string
2023-design-movie-rental-system
3610-find-x-sum-of-all-k-long-subarrays-i
3863-power-grid-maintenance

Queue

2408-number-of-people-aware-of-a-secret
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3827-implement-router

Prefix Sum

2529-range-product-queries-of-powers
3475-minimum-operations-to-make-binary-array-elements-equal-to-one-i
3789-maximize-subarrays-after-removing-one-conflicting-pair

Interactive

0278-first-bad-version

String Matching

0812-rotate-string

Tree

1218-lowest-common-ancestor-of-deepest-leaves

Depth-First Search

1218-lowest-common-ancestor-of-deepest-leaves
3863-power-grid-maintenance

Breadth-First Search

0833-bus-routes
1218-lowest-common-ancestor-of-deepest-leaves
1424-maximum-candies-you-can-get-from-boxes
3863-power-grid-maintenance

Binary Tree

1218-lowest-common-ancestor-of-deepest-leaves

Design

1249-snapshot-array
2023-design-movie-rental-system
3827-implement-router

Dynamic Programming

0120-triangle
0121-best-time-to-buy-and-sell-stock
0934-bitwise-ors-of-subarrays
1402-count-square-submatrices-with-all-ones
1586-longest-subarray-of-1s-after-deleting-one-element
2028-the-earliest-and-latest-rounds-where-players-compete
2408-number-of-people-aware-of-a-secret
2755-extra-characters-in-a-string
2882-ways-to-express-an-integer-as-sum-of-powers
3648-find-the-maximum-number-of-fruits-collected

Trie

2755-extra-characters-in-a-string

Graph

1424-maximum-candies-you-can-get-from-boxes
3863-power-grid-maintenance

Union Find

1058-lexicographically-smallest-equivalent-string
3863-power-grid-maintenance

Memoization

2028-the-earliest-and-latest-rounds-where-players-compete

Segment Tree

3789-maximize-subarrays-after-removing-one-conflicting-pair

Brainteaser

2503-longest-subarray-with-maximum-bitwise-and

Divide and Conquer

0169-majority-element
0347-top-k-frequent-elements

Bucket Sort

0347-top-k-frequent-elements

Quickselect

0347-top-k-frequent-elements

Ordered Set

2023-design-movie-rental-system
3827-implement-router
3863-power-grid-maintenance

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages