Skip to content

AdrishikharChowdhury/Leetcode-problems-answers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

A collection of solutions to LeetCode problems, categorized by difficulty and topic.

Table of Contents

Introduction

This repository contains solutions to various LeetCode problems. Each solution includes the problem statement, the approach used to solve the problem, and the implementation in different programming languages.

Usage

Navigate to the directory of the problem you want to view and open the corresponding solution file.

Example:

cd Easy/problem1
cat solution.py

Contributing

Contributions are welcome! If you have a solution to a LeetCode problem that is not already in this repository, feel free to add it.

  1. Fork the repository.
  2. Create a new branch (git checkout -b new-solution).
  3. Add your solution in the appropriate directory.
  4. Commit your changes (git commit -m 'Add new solution').
  5. Push to the branch (git push origin new-solution).
  6. Open a pull request.
  7. Please ensure your code follows the style and structure of the existing solutions.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contact

If you have any questions or suggestions, feel free to contact me:

Email: [email protected]

GitHub: AdrishikharChowdhury

LeetCode Topics

String

0017-letter-combinations-of-a-phone-number
0072-edit-distance
0125-valid-palindrome
0151-reverse-words-in-a-string
0344-reverse-string
0443-string-compression
0567-permutation-in-string
0952-word-subsets
1250-longest-common-subsequence
1502-construct-k-palindrome-strings
1524-string-matching-in-an-array
1537-maximum-score-after-splitting-a-string
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
2221-check-if-a-parentheses-string-can-be-valid
2292-counting-words-with-a-given-prefix
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges
3309-count-prefix-and-suffix-pairs-i
3455-minimum-length-of-string-after-operations

Prefix Sum

0238-product-of-array-except-self
1537-maximum-score-after-splitting-a-string
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
2394-count-subarrays-with-score-less-than-k
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges

Array

0011-container-with-most-water
0031-next-permutation
0033-search-in-rotated-sorted-array
0036-valid-sudoku
0037-sudoku-solver
0075-sort-colors
0088-merge-sorted-array
0121-best-time-to-buy-and-sell-stock
0136-single-number
0162-find-peak-element
0198-house-robber
0204-count-primes
0216-combination-sum-iii
0238-product-of-array-except-self
0407-trapping-rain-water-ii
0494-target-sum
0540-single-element-in-a-sorted-array
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
0747-min-cost-climbing-stairs
0854-making-a-large-island
0882-peak-index-in-a-mountain-array
0907-koko-eating-bananas
0952-word-subsets
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
1876-map-of-highest-peak
1878-check-if-array-is-sorted-and-rotated
1895-minimum-number-of-operations-to-move-all-balls-to-each-box
1927-maximum-ascending-subarray-sum
2145-grid-game
2292-counting-words-with-a-given-prefix
2358-number-of-ways-to-split-array
2392-successful-pairs-of-spells-and-potions
2394-count-subarrays-with-score-less-than-k
2448-count-number-of-bad-pairs
2465-shifting-letters-ii
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2533-bitwise-xor-of-all-pairings
2685-first-completely-painted-row-or-column
2691-count-vowel-strings-in-ranges
2764-maximum-number-of-fish-in-a-grid
2766-find-the-prefix-common-array-of-two-arrays
2792-neighboring-bitwise-xor
3309-count-prefix-and-suffix-pairs-i
3372-longest-strictly-increasing-or-strictly-decreasing-subarray
3429-special-array-i
3434-find-the-number-of-distinct-colors-among-the-balls
3748-sort-matrix-by-diagonals

Dynamic Programming

0062-unique-paths
0072-edit-distance
0121-best-time-to-buy-and-sell-stock
0198-house-robber
0338-counting-bits
0494-target-sum
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
0747-min-cost-climbing-stairs
0806-domino-and-tromino-tiling
1236-n-th-tribonacci-number
1250-longest-common-subsequence

Backtracking

0017-letter-combinations-of-a-phone-number
0037-sudoku-solver
0216-combination-sum-iii
0494-target-sum

Hash Table

0017-letter-combinations-of-a-phone-number
0036-valid-sudoku
0037-sudoku-solver
0567-permutation-in-string
0952-word-subsets
1364-tuple-with-same-product
1500-count-largest-group
1502-construct-k-palindrome-strings
1915-check-if-one-string-swap-can-make-strings-equal
2059-unique-length-3-palindromic-subsequences
2434-design-a-number-container-system
2448-count-number-of-bad-pairs
2473-max-sum-of-a-pair-with-equal-sum-of-digits
2685-first-completely-painted-row-or-column
2766-find-the-prefix-common-array-of-two-arrays
3434-find-the-number-of-distinct-colors-among-the-balls
3455-minimum-length-of-string-after-operations

Bit Manipulation

0136-single-number
0338-counting-bits
1441-minimum-flips-to-make-a-or-b-equal-to-c
2059-unique-length-3-palindromic-subsequences
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2766-find-the-prefix-common-array-of-two-arrays
2792-neighboring-bitwise-xor

Two Pointers

0011-container-with-most-water
0031-next-permutation
0075-sort-colors
0088-merge-sorted-array
0125-valid-palindrome
0151-reverse-words-in-a-string
0344-reverse-string
0443-string-compression
0567-permutation-in-string
2392-successful-pairs-of-spells-and-potions

Binary Search

0033-search-in-rotated-sorted-array
0162-find-peak-element
0540-single-element-in-a-sorted-array
0882-peak-index-in-a-mountain-array
0907-koko-eating-bananas
2392-successful-pairs-of-spells-and-potions
2394-count-subarrays-with-score-less-than-k

Sorting

0075-sort-colors
0088-merge-sorted-array
2392-successful-pairs-of-spells-and-potions
2473-max-sum-of-a-pair-with-equal-sum-of-digits
3748-sort-matrix-by-diagonals

String Matching

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

Tree

0515-find-largest-value-in-each-tree-row
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
1396-count-servers-that-communicate
2246-maximum-employees-to-be-invited-to-a-meeting
2764-maximum-number-of-fish-in-a-grid
3439-find-minimum-diameter-after-merging-two-trees

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
1396-count-servers-that-communicate
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1876-map-of-highest-peak
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

Binary Tree

0515-find-largest-value-in-each-tree-row

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

Math

0007-reverse-integer
0009-palindrome-number
0050-powx-n
0062-unique-paths
0204-count-primes
1236-n-th-tribonacci-number
1500-count-largest-group
2448-count-number-of-bad-pairs

Memoization

1236-n-th-tribonacci-number

Combinatorics

0062-unique-paths

Greedy

0011-container-with-most-water
0714-best-time-to-buy-and-sell-stock-with-transaction-fee
1502-construct-k-palindrome-strings
2221-check-if-a-parentheses-string-can-be-valid
2509-minimize-xor

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
2448-count-number-of-bad-pairs
3455-minimum-length-of-string-after-operations

Recursion

0050-powx-n

Stack

2021-remove-all-occurrences-of-a-substring
2221-check-if-a-parentheses-string-can-be-valid

Graph

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

Brainteaser

2533-bitwise-xor-of-all-pairings

Heap (Priority Queue)

0407-trapping-rain-water-ii
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
2434-design-a-number-container-system
2473-max-sum-of-a-pair-with-equal-sum-of-digits

Matrix

0036-valid-sudoku
0037-sudoku-solver
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
3748-sort-matrix-by-diagonals

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

Topological Sort

0820-find-eventual-safe-states
2246-maximum-employees-to-be-invited-to-a-meeting

Simulation

2021-remove-all-occurrences-of-a-substring
3434-find-the-number-of-distinct-colors-among-the-balls

Sliding Window

0567-permutation-in-string
2394-count-subarrays-with-score-less-than-k

Design

2434-design-a-number-container-system

Ordered Set

2434-design-a-number-container-system

Enumeration

0204-count-primes

Number Theory

0204-count-primes

About

In this repository there are some Leetcode solutions I have done

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published