Skip to content

hawkh/Leetcode-Solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA-Solutions

Collection of LeetCode ,Smart Interviews,Interviewbit,Codeforces questions etc I have solved till date

Overview

This repository contains solutions to various problems on InterviewBit,Leetcode,Smart Interviews covering a wide range of topics and difficulty levels. The code snippets provided are as solved on the platform.


Available Topics

The repository includes solutions for problems in the following categories:

  • Programming: Comprehensive solutions across all major domains, including arrays, strings, dynamic programming, graph algorithms, and more.

How to Contribute?

Steps to Contribute

  1. Fork the Repository: Start by forking this repository to your own GitHub account.
  2. Make Changes: Add, delete, or modify the solutions as needed.
  3. Create a Pull Request: Submit your changes for review by creating a pull request.

When to Contribute?

Contributions are welcome under the following scenarios:

  1. New Solutions:
    • If a problem lacks a solution in the main branch, feel free to add your implementation.
  2. Improved Solutions:
    • If your solution is asymptotically faster than the existing one, replace the original with your implementation.
    • If your algorithm has the same time complexity but with reduced code size, comment out the original solution and provide your optimized version.
  3. Alternative Methods:
    • If your approach is slower but offers an interesting perspective or learning value, comment it within the main file alongside the original solution.

Notes

  • Please ensure your contributions are well-documented with appropriate comments.
  • Adhere to the repository's structure and naming conventions for consistency.
  • Test your solutions on respective platforms before submitting.

Contributions to this repository not only enhance its utility but also help the community prepare better for coding interviews. Happy coding! 🎉

LeetCode Topics

Array

0015-3sum
0026-remove-duplicates-from-sorted-array
0027-remove-element
0042-trapping-rain-water
0053-maximum-subarray
0074-search-a-2d-matrix
0121-best-time-to-buy-and-sell-stock
0128-longest-consecutive-sequence
0136-single-number
0153-find-minimum-in-rotated-sorted-array
0162-find-peak-element
0204-count-primes
0217-contains-duplicate
0219-contains-duplicate-ii
0238-product-of-array-except-self
0240-search-a-2d-matrix-ii
0287-find-the-duplicate-number
0485-max-consecutive-ones
0540-single-element-in-a-sorted-array
0560-subarray-sum-equals-k
0817-design-hashmap
1331-path-with-maximum-gold
1476-count-negative-numbers-in-a-sorted-matrix
2232-adding-spaces-to-a-string
2551-apply-operations-to-an-array
2868-continuous-subarrays
3555-final-array-state-after-k-multiplication-operations-i

Hash Table

0128-longest-consecutive-sequence
0141-linked-list-cycle
0217-contains-duplicate
0219-contains-duplicate-ii
0560-subarray-sum-equals-k
0817-design-hashmap
2599-take-k-of-each-character-from-left-and-right
3267-find-longest-special-substring-that-occurs-thrice-i

Prefix Sum

0238-product-of-array-except-self
0560-subarray-sum-equals-k

String

0020-valid-parentheses
0647-palindromic-substrings
1894-merge-strings-alternately
2076-sum-of-digits-of-string-after-convert
2232-adding-spaces-to-a-string
2599-take-k-of-each-character-from-left-and-right
3267-find-longest-special-substring-that-occurs-thrice-i

Sliding Window

0219-contains-duplicate-ii
2599-take-k-of-each-character-from-left-and-right
2868-continuous-subarrays
3267-find-longest-special-substring-that-occurs-thrice-i

Bit Manipulation

0136-single-number
0190-reverse-bits
0191-number-of-1-bits
0201-bitwise-and-of-numbers-range
0231-power-of-two
0287-find-the-duplicate-number
0338-counting-bits
0371-sum-of-two-integers
2323-minimum-bit-flips-to-convert-number

Divide and Conquer

0053-maximum-subarray
0190-reverse-bits
0191-number-of-1-bits
0240-search-a-2d-matrix-ii

Math

0007-reverse-integer
0069-sqrtx
0204-count-primes
0231-power-of-two
0371-sum-of-two-integers
1236-n-th-tribonacci-number
3555-final-array-state-after-k-multiplication-operations-i

Recursion

0021-merge-two-sorted-lists
0231-power-of-two

Dynamic Programming

0042-trapping-rain-water
0053-maximum-subarray
0121-best-time-to-buy-and-sell-stock
0338-counting-bits
0647-palindromic-substrings
1236-n-th-tribonacci-number

Two Pointers

0015-3sum
0026-remove-duplicates-from-sorted-array
0027-remove-element
0042-trapping-rain-water
0141-linked-list-cycle
0287-find-the-duplicate-number
0647-palindromic-substrings
1894-merge-strings-alternately
2232-adding-spaces-to-a-string
2551-apply-operations-to-an-array

Simulation

2076-sum-of-digits-of-string-after-convert
2232-adding-spaces-to-a-string
2551-apply-operations-to-an-array
3555-final-array-state-after-k-multiplication-operations-i

Enumeration

0204-count-primes

Number Theory

0204-count-primes

Union Find

0128-longest-consecutive-sequence

Linked List

0021-merge-two-sorted-lists
0141-linked-list-cycle
0817-design-hashmap

Backtracking

1331-path-with-maximum-gold

Matrix

0074-search-a-2d-matrix
0240-search-a-2d-matrix-ii
1331-path-with-maximum-gold
1476-count-negative-numbers-in-a-sorted-matrix

Binary Search

0069-sqrtx
0074-search-a-2d-matrix
0153-find-minimum-in-rotated-sorted-array
0162-find-peak-element
0240-search-a-2d-matrix-ii
0287-find-the-duplicate-number
0540-single-element-in-a-sorted-array
1476-count-negative-numbers-in-a-sorted-matrix
3267-find-longest-special-substring-that-occurs-thrice-i

Counting

3267-find-longest-special-substring-that-occurs-thrice-i

Design

0817-design-hashmap

Hash Function

0817-design-hashmap

Queue

2868-continuous-subarrays

Heap (Priority Queue)

2868-continuous-subarrays
3555-final-array-state-after-k-multiplication-operations-i

Ordered Set

2868-continuous-subarrays

Monotonic Queue

2868-continuous-subarrays

Stack

0020-valid-parentheses
0042-trapping-rain-water

Monotonic Stack

0042-trapping-rain-water

Tree

0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0235-lowest-common-ancestor-of-a-binary-search-tree
0437-path-sum-iii
0450-delete-node-in-a-bst
0904-leaf-similar-trees

Breadth-First Search

0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree

Binary Tree

0102-binary-tree-level-order-traversal
0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0235-lowest-common-ancestor-of-a-binary-search-tree
0437-path-sum-iii
0450-delete-node-in-a-bst
0904-leaf-similar-trees

Depth-First Search

0104-maximum-depth-of-binary-tree
0110-balanced-binary-tree
0235-lowest-common-ancestor-of-a-binary-search-tree
0437-path-sum-iii
0904-leaf-similar-trees

Binary Search Tree

0235-lowest-common-ancestor-of-a-binary-search-tree
0450-delete-node-in-a-bst

Sorting

0015-3sum
0217-contains-duplicate

Memoization

1236-n-th-tribonacci-number

About

Collection of LeetCode questions I have solved

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published