Skip to content

Strikezor/Leetcode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Problem Solutions in C++

Welcome to my LeetCode problem solutions repository! Here, you'll find comprehensive solutions to a wide range of LeetCode problems, all implemented in C++. Whether you're preparing for technical interviews or just looking to sharpen your algorithm skills, this repository is designed to help you understand and master common coding challenges.

Why C++?

C++ is a powerful and versatile programming language, particularly well-suited for competitive programming and algorithmic problem-solving. Its performance and efficiency make it a popular choice for coding interviews and contests like LeetCode. By providing solutions in C++, this repository aims to showcase effective problem-solving techniques and best practices in this language.

Learning and Improvement

This repository is not just about providing answers to problems; it's also about learning and improvement. Each solution is crafted to be clear, concise, and well-structured, making it easier for you to understand and learn from. Additionally, the solutions are continuously updated and refined to incorporate feedback and improvements, ensuring that you have access to high-quality, up-to-date content.

How to Use

To make the most of this repository, simply browse through the files to find the problem you're interested in. Each problem is contained with the C++ source code file (.cpp).

Contribution

Contributions to this repository are welcome! If you have a new solution to a problem, an improvement to an existing solution, or a suggestion for how to make this repository better, feel free to submit a pull request. Your contributions help make this repository a valuable resource for the programming community.

LeetCode Topics

Tree

0101-symmetric-tree
0515-find-largest-value-in-each-tree-row
0925-construct-binary-tree-from-preorder-and-postorder-traversal
1387-find-elements-in-a-contaminated-binary-tree
2564-most-profitable-path-in-a-tree
3439-find-minimum-diameter-after-merging-two-trees

Depth-First Search

0101-symmetric-tree
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
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
3439-find-minimum-diameter-after-merging-two-trees

Breadth-First Search

0101-symmetric-tree
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
1424-maximum-candies-you-can-get-from-boxes
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

Binary Tree

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

Graph

0684-redundant-connection
0820-find-eventual-safe-states
1424-maximum-candies-you-can-get-from-boxes
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

Array

0135-candy
0407-trapping-rain-water-ii
0494-target-sum
0854-making-a-large-island
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1006-vowel-spellchecker
1025-minimum-cost-for-tickets
1063-best-sightseeing-pair
1364-tuple-with-same-product
1396-count-servers-that-communicate
1424-maximum-candies-you-can-get-from-boxes
1477-product-of-the-last-k-numbers
1485-minimum-cost-to-make-at-least-one-valid-path-in-a-grid
1524-string-matching-in-an-array
1631-number-of-sub-arrays-with-odd-sum
1819-construct-the-lexicographically-largest-valid-sequence
1834-minimum-number-of-people-to-teach
1849-maximum-absolute-sum-of-any-subarray
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
2107-find-unique-binary-string
2145-grid-game
2265-partition-array-according-to-given-pivot
2292-counting-words-with-a-given-prefix
2307-replace-non-coprime-numbers-in-array
2358-number-of-ways-to-split-array
2429-design-a-food-rating-system
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
2551-apply-operations-to-an-array
2564-most-profitable-path-in-a-tree
2685-first-completely-painted-row-or-column
2691-count-vowel-strings-in-ranges
2707-merge-two-2d-arrays-by-summing-values
2764-maximum-number-of-fish-in-a-grid
2792-neighboring-bitwise-xor
3219-make-lexicographically-smallest-array-by-swapping-elements
3309-count-prefix-and-suffix-pairs-i
3332-minimum-operations-to-exceed-threshold-value-ii
3372-longest-strictly-increasing-or-strictly-decreasing-subarray
3434-find-the-number-of-distinct-colors-among-the-balls

Dynamic Programming

0494-target-sum
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
1849-maximum-absolute-sum-of-any-subarray
2562-count-ways-to-build-good-strings

Backtracking

0494-target-sum
1160-letter-tile-possibilities
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

String

0012-integer-to-roman
0013-roman-to-integer
0952-word-subsets
1006-vowel-spellchecker
1160-letter-tile-possibilities
1170-shortest-common-supersequence
1264-maximum-number-of-words-you-can-type
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
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
2429-design-a-food-rating-system
2456-construct-smallest-number-from-di-string
2465-shifting-letters-ii
2691-count-vowel-strings-in-ranges
2887-sort-vowels-in-a-string
3309-count-prefix-and-suffix-pairs-i
3447-clear-digits
3455-minimum-length-of-string-after-operations
3462-vowels-game-in-a-string
3872-find-most-frequent-vowel-and-consonant

Prefix Sum

1477-product-of-the-last-k-numbers
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

Hash Table

0012-integer-to-roman
0013-roman-to-integer
0905-length-of-longest-fibonacci-subsequence
0925-construct-binary-tree-from-preorder-and-postorder-traversal
0952-word-subsets
1006-vowel-spellchecker
1160-letter-tile-possibilities
1264-maximum-number-of-words-you-can-type
1364-tuple-with-same-product
1387-find-elements-in-a-contaminated-binary-tree
1502-construct-k-palindrome-strings
1834-minimum-number-of-people-to-teach
1915-check-if-one-string-swap-can-make-strings-equal
2059-unique-length-3-palindromic-subsequences
2107-find-unique-binary-string
2429-design-a-food-rating-system
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
2707-merge-two-2d-arrays-by-summing-values
3434-find-the-number-of-distinct-colors-among-the-balls
3455-minimum-length-of-string-after-operations
3872-find-most-frequent-vowel-and-consonant

Bit Manipulation

2059-unique-length-3-palindromic-subsequences
2509-minimize-xor
2533-bitwise-xor-of-all-pairings
2792-neighboring-bitwise-xor

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

Greedy

0135-candy
1502-construct-k-palindrome-strings
1834-minimum-number-of-people-to-teach
2221-check-if-a-parentheses-string-can-be-valid
2456-construct-smallest-number-from-di-string
2509-minimize-xor

Counting

1160-letter-tile-possibilities
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
3872-find-most-frequent-vowel-and-consonant

Stack

2021-remove-all-occurrences-of-a-substring
2221-check-if-a-parentheses-string-can-be-valid
2307-replace-non-coprime-numbers-in-array
2456-construct-smallest-number-from-di-string
3447-clear-digits

Brainteaser

2533-bitwise-xor-of-all-pairings
3462-vowels-game-in-a-string

Heap (Priority Queue)

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

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

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

Sorting

2473-max-sum-of-a-pair-with-equal-sum-of-digits
2887-sort-vowels-in-a-string
3219-make-lexicographically-smallest-array-by-swapping-elements

Simulation

2021-remove-all-occurrences-of-a-substring
2265-partition-array-according-to-given-pivot
2551-apply-operations-to-an-array
3332-minimum-operations-to-exceed-threshold-value-ii
3434-find-the-number-of-distinct-colors-among-the-balls
3447-clear-digits

Design

1387-find-elements-in-a-contaminated-binary-tree
1477-product-of-the-last-k-numbers
2429-design-a-food-rating-system
2434-design-a-number-container-system

Ordered Set

2429-design-a-food-rating-system
2434-design-a-number-container-system

Math

0012-integer-to-roman
0013-roman-to-integer
1440-convert-integer-to-the-sum-of-two-no-zero-integers
1477-product-of-the-last-k-numbers
1631-number-of-sub-arrays-with-odd-sum
2307-replace-non-coprime-numbers-in-array
2448-count-number-of-bad-pairs
2802-find-the-punishment-number-of-an-integer
3462-vowels-game-in-a-string

Data Stream

1477-product-of-the-last-k-numbers

Divide and Conquer

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

Two Pointers

2265-partition-array-according-to-given-pivot
2551-apply-operations-to-an-array
2707-merge-two-2d-arrays-by-summing-values

Game Theory

3462-vowels-game-in-a-string

Number Theory

2307-replace-non-coprime-numbers-in-array

About

This is a Repository for my LeetCode Submissions, Feel free to check them out!

Topics

Resources

Stars

Watchers

Forks

Languages