Skip to content

Latest commit

 

History

History
143 lines (134 loc) · 28.9 KB

README.md

File metadata and controls

143 lines (134 loc) · 28.9 KB

Leetcode Problems Solutions

"The only way to do great work is to love what you do." -Steve Jobs

This repository contains my solutions to various Leetcode problems. Below is a table listing all the problems, along with their tags, difficulty level, and a checkbox for you to mark if you've solved the problem.

Feel free to fork this repository and contribute by adding more problems or improving the existing solutions.

Problems List

ID Title Tags Difficulty Solved Solution File
1 Two Sum Array, Hash Table Easy ✔️ Two Sum.java
2 Add Two Numbers Linked List, Math Medium ✔️ Add 2 Number.java
3 Longest Substring Without Repeating Characters Hash Table, String, Sliding Window Medium ✔️ Longest Substring Without Repeatition.java
4 Median of Two Sorted Arrays Array, Binary Search Hard ✔️ Median Of 2 Sorted Array.java
5 Longest Palindromic Substring String, Dynamic Programming Medium
6 ZigZag Conversion String Medium
7 Reverse Integer Math Easy ✔️ Reverse Integer.java
8 String to Integer (atoi) String Medium ✔️ String To Integer.java
9 Palindrome Number Math Easy ✔️ Pallindrome Number.java
10 Regular Expression Matching String, Dynamic Programming Hard
11 Container With Most Water Array, Two Pointers Medium
12 Integer to Roman Math Medium ✔️ Integer To Roman.java
13 Roman to Integer Math Easy ✔️ Roman To Integer.java
14 Longest Common Prefix String Easy ✔️ Longest Common Prefix.java
15 3Sum Array, Two Pointers Medium Letter Combination Of Phone Number.java
16 3Sum Closest Array, Two Pointers Medium
17 Letter Combinations of a Phone Number Backtracking, String Medium ✔️ Letter Combination Of Phone Numbers.java
18 4Sum Array, Two Pointers Medium
19 Remove Nth Node From End of List Linked List Medium ✔️ Remove Nth Node From End.java
20 Valid Parentheses Stack, String Easy ✔️ Valid Paranthesis.java
21 Merge Two Sorted Lists Linked List Easy ✔️ Merge Two Sorted Lists.java
22 Generate Parentheses Backtracking Medium ✔️ Generate Parantheses.java
23 Merge k Sorted Lists Linked List, Divide and Conquer Hard ✔️ Merge K Sorted Lists.java
24 Swap Nodes in Pairs Linked List Medium Solution24.java
25 Reverse Nodes in k-Group Linked List Hard ✔️ Reverse Nodes In K Groups.java
26 Remove Duplicates from Sorted Array Array Easy ✔️ Remove Duplicates From Sorted Array.java
27 Remove Element Array Easy ✔️ Remove Element.java
28 Find the Index Of First Occurence In A String String Easy ✔️ Index Of First Occurence In A String.java
29 Divide Two Integers Math Medium Solution29.java
30 Substring with Concatenation of All Words Hash Table, String, Sliding Window Hard Solution30.java
31 Next Permutation Array, Two Pointers Medium Solution31.java
32 Longest Valid Parentheses String, Stack Hard ✔️ Longest Valid Parantheses.java
33 Search in Rotated Sorted Array Array, Binary Search Medium ✔️ Search In Rotated Sorted Array.java
34 Find First and Last Position of Element in Sorted Array Array, Binary Search Medium ✔️ First And Last Position Of Element In Sorted Array.java
35 Search Insert Position Array, Binary Search Easy ✔️ Search Insert Position.java
36 Valid Sudoku Array, Hash Table Medium Solution36.java
37 Sudoku Solver Backtracking Hard Solution37.java
38 Count and Say String Easy Solution38.java
39 Combination Sum Backtracking Medium Solution39.java
40 Combination Sum II Backtracking Medium Solution40.java
41 First Missing Positive Array Hard ✔️ First Missing Positive.java
42 Trapping Rain Water Array, Two Pointers Hard ✔️ Trapping Rain Water.java
43 Multiply Strings Math, String Medium Solution43.java
44 Wildcard Matching String, Dynamic Programming Hard Solution44.java
45 Jump Game II Array, Greedy Hard Solution45.java
46 Permutations Backtracking Medium Solution46.java
47 Permutations II Backtracking Medium Solution47.java
48 Rotate Image Array Medium Solution48.java
49 Group Anagrams Hash Table, String Medium ✔️ Group Anagrams.java
50 Pow(x, n) Math Medium Solution50.java
51 N-Queens Backtracking Hard Solution51.java
52 N-Queens II Backtracking Hard Solution52.java
53 Maximum Subarray Array, Dynamic Programming Easy Solution53.java
54 Spiral Matrix Array Medium Spiral Matrix.java
55 Jump Game Array, Greedy Medium Solution55.java
56 Merge Intervals Array, Sorting Medium Solution56.java
57 Insert Interval Array Hard Solution57.java
58 Length of Last Word String Easy ✔️ Length Of Last Word.java
59 Spiral Matrix II Array Medium Spiral MatrixII.java
60 Permutation Sequence Math, Backtracking Hard Solution60.java
61 Rotate List Linked List Medium ✔️ Rotate List.java
62 Unique Paths Dynamic Programming Medium Solution62.java
63 Unique Paths II Dynamic Programming Medium Solution63.java
64 Minimum Path Sum Dynamic Programming Medium Solution64.java
65 Valid Number String Hard Solution65.java
66 Plus One Array Easy ✔️ Plus One.java
67 Add Binary String, Math Easy ✔️ Add Binary.java
68 Text Justification String Hard Solution68.java
69 Sqrt(x) Binary Search, Math Easy ✔️ Sqrt Of X.java
70 Climbing Stairs Dynamic Programming Easy ✔️ Climbing Stairs.java
71 Simplify Path Stack, String Medium Solution71.java
72 Edit Distance String, Dynamic Programming Hard ✔️ Edit Distance.java
73 Set Matrix Zeroes Array Medium Solution73.java
74 Search a 2D Matrix Array, Binary Search Medium Solution74.java
75 Sort Colors Array, Two Pointers Medium ✔️ Sort Colors.java
76 Minimum Window Substring Hash Table, String, Sliding Window Hard Solution76.java
77 Combinations Backtracking Medium Solution77.java
78 Subsets Backtracking Medium Solution78.java
79 Word Search Backtracking Medium ✔️ Word Search.java
80 Remove Duplicates from Sorted Array II Array Medium Solution80.java
81 Search in Rotated Sorted Array II Array Medium Solution81.java
82 Remove Duplicates from Sorted List II Linked List Medium Remove Duplicates From Sorted List.java
83 Remove Duplicates from Sorted List Linked List Easy ✔️ Solution83.java
84 Largest Rectangle in Histogram Array, Stack Hard Solution84.java
85 Maximal Rectangle Array, Stack Hard Solution85.java
86 Partition List Linked List Medium Solution86.java
87 Scramble String String, Dynamic Programming Hard Solution87.java
88 Merge Sorted Array Array Easy ✔️ Merge Sorted List.java
89 Gray Code Bit Manipulation Medium Solution89.java
90 Subsets II Backtracking Medium Solution90.java
91 Decode Ways Dynamic Programming Medium Solution91.java
92 Reverse Linked List II Linked List Medium Solution92.java
93 Restore IP Addresses Backtracking Medium Solution93.java
94 Binary Tree Inorder Traversal Tree, Stack Easy ✔️ Binary Tree InOrder Traversal.java
95 Unique Binary Search Trees II Tree, Dynamic Programming Medium Solution95.java
96 Unique Binary Search Trees Tree, Dynamic Programming Medium Solution96.java
97 Interleaving String String, Dynamic Programming Hard Solution97.java
98 Validate Binary Search Tree Tree, Depth First Search Medium Solution98.java
99 Recover Binary Search Tree Tree, Depth First Search Hard Solution99.java
100 Same Tree Tree, Depth First Search, Breadth First Search Hard ✔️ Solution100.java

| ... | ... | ... | ... | [ ] |

Usage

  1. Clone the repository:
    git clone https://github.com/yourusername/leetcode-solutions.git
  2. Navigate to the directory:
    cd leetcode-solutions
  3. Create a new branch:
    git checkout -b new-branch
  4. Add your solutions:
  5. Commit your changes:
    git commit -am "Added solutions to problem 1 and problem 2"
  6. Push to the branch:
    git push origin new-branch
  7. Submit a pull request
  8. Star the repository
  9. Relax and wait for your PR to be merged
  10. Celebrate - you've done your part! 🎉