/LeetCode

Solutions for LeetCode Problems

Primary LanguageC++MIT LicenseMIT

LeetCode

Solutions for LeetCode

Typing SVG

/**
 * @brief:   This repository contains my solutions for leetcode problems.
 * @author:  SahilK-027
 * @param:   Takes logic
 * @return:  Solutions
*/
solutions main(logic)
{
  if(Like the repository)
  {
    Give ⭐️;
    Thanks 😊;
  }
  return (My LeetCode solutions);
}

Travis Travis

@@  Problems Solved So Far,... @@
# Problem Title Difficulty Solution
1 Two Sum 🟢 solution
2 Add Two Numbers 🟡 solution
3 Longest Substring Without Repeating Characters 🟡 solution
4 Median of Two Sorted Arrays 🔴 solution
7 Reverse Integer 🟡 solution
9 Palindrome Number 🟢 solution
11 Container With Most Water 🟡 solution
13 Roman to Integer 🟢 solution
14 Longest Common Prefix 🟢 solution
15 3Sum 🟡 solution
17 Letter Combinations of a Phone Number 🟡 solution
18 4Sum 🟡 solution
19 Remove Nth Node From End of List 🟡 solution
20 Valid Parentheses 🟢 solution
21 Merge Two Sorted Lists 🟢 solution
22 Generate Parentheses 🟡 solution
23 Merge k Sorted Lists 🔴 solution
24 Swap Nodes in Pairs 🟡 solution
25 Reverse Nodes in k-Group 🔴 solution
26 Remove Duplicates from Sorted Array 🟢 solution
27 Remove Element 🟢 solution
28 Find the Index of the First Occurrence in a String 🟡 solution
33 Search in Rotated Sorted Array 🟡 solution
34 Find First and Last Position of Element in Sorted Array 🟡 solution
35 Search Insert Position 🟢 solution
37 Sudoku Solver 🔴 solution
42 Trapping Rain Water 🔴 solution
45 Jump Game II 🟡 solution
46 Permutations 🟡 solution
48 Rotate Image 🟡 solution
49 Group Anagram 🟡 solution
50 Pow(x, n) 🟡 solution
51 N-Queens 🔴 solution
52 N-Queens II 🔴 solution
53 Maximum Subarray 🟡 solution
54 Spiral Matrix 🟡 solution
55 Jump Game 🟡 solution
58 Length of Last Word 🟢 solution
59 Spiral Matrix II 🟡 solution
61 Rotate List 🟡 solution
66 Plus One 🟢 solution
69 Sqrt(x) 🟢 solution
70 Climbing Stairs 🟢 solution
73 Set Matrix Zeroes 🟡 solution
74 Search a 2D Matrix 🟡 solution
78 Subsets 🟡 solution
82 Remove Duplicates from Sorted List II 🟡 solution
83 Remove Duplicates from Sorted List 🟢 solution
84 Largest Rectangle in Histogram 🔴 solution
85 Maximal Rectangle 🔴 solution
86 Partition List 🟡 solution
88 Merge Sorted Array 🟢 solution
91 Decode Ways 🟡 solution
92 Reverse Linked List II 🟡 solution
94 Binary Tree Inorder Traversal 🟢 solution
96 Unique Binary Search Trees 🟡 solution
98 Validate Binary Search Tree 🟡 solution
100 Same Tree 🟢 solution
101 Symmetric Tree 🟢 solution
102 Binary Tree Level Order Traversal 🟡 solution
103 Binary Tree Zigzag Level Order Traversal 🟡 solution
104 Maximum Depth of Binary Tree 🟢 solution
105 Construct Binary Tree from Preorder and Inorder Traversal 🟡 solution
106 Construct Binary Tree from Inorder and Postorder Traversal 🟡 solution
107 Binary Tree Level Order Traversal II 🟡 solution
108 Convert Sorted Array to Binary Search Tree 🟢 solution
109 Convert Sorted List to Binary Search Tree 🟡 solution
110 Balanced Binary Tree 🟢 solution
111 Minimum Depth of Binary Tree 🟢 solution
112 Path Sum 🟢 solution
114 Flatten Binary Tree to Linked List 🟡 solution
121 Best Time to Buy and Sell Stock 🟢 solution
124 Binary Tree Maximum Path Sum 🔴 solution
129 Sum Root to Leaf Numbers 🟡 solution
138 Copy List with Random Pointer 🟡 solution
140 Word Break II 🔴 solution
141 Linked List Cycle 🟢 solution
142 Linked List Cycle II 🟡 solution
143 Reorder List 🟡 solution
144 Binary Tree Preorder Traversal 🟢 solution
145 Binary Tree Postorder Traversal 🟢 solution
148 Sort List 🟡 solution
150 Evaluate Reverse Polish Notation 🟡 solution
151 Reverse Words in a String 🟡 solution
153 Find Minimum in Rotated Sorted Array 🟡 solution
160 Intersection of Two Linked Lists 🟢 solution
162 Find Peak Element 🟡 solution
167 Two Sum II - Input Array Is Sorted 🟡 solution
189 Rotate Array 🟡 solution
191 Number of 1 Bits 🟢 solution
198 House Robber 🟡 solution
191 Number of 1 Bits 🟢 solution
199 Binary Tree Right Side View 🟡 solution
202 Happy Number 🟢 solution
203 Remove Linked List Elements 🟢 solution
204 Count Primes 🟡 solution
206 Reverse Linked List 🟢 solution
208 Implement Trie (Prefix Tree) 🟡 solution
213 House Robber II 🟡 solution
215 Kth Largest Element in an Array 🟡 solution
217 Contains Duplicate 🟢 solution
222 Count Complete Tree Nodes 🟡 solution
226 Invert Binary Tree 🟢 solution
230 Kth Smallest Element in a BST 🟡 solution
231 Power of Two 🟢 solution
232 Implement Queue using Stacks 🟢 solution
233 Number of Digit One 🔴 solution
234 Palindrome Linked List 🟢 solution
235 Lowest Common Ancestor of a Binary Search Tree 🟡 solution
236 Lowest Common Ancestor of a Binary Tree 🟡 solution
237 Delete Node in a Linked List 🟡 solution
239 Sliding Window Maximum 🔴 solution
240 Search a 2D Matrix II 🟡 solution
257 Binary Tree Paths 🟢 solution
263 Ugly Number 🟢 solution
268 Missing Number 🟢 solution
273 Integer to English Words 🔴 solution
278 First Bad Version 🟢 solution
283 Move Zeroes 🟢 solution
290 Word Pattern 🟢 solution
301 Remove Invalid Parentheses 🔴 solution
309 Best Time to Buy and Sell Stock with Cooldown 🟡 solution
301 Remove Invalid Parentheses 🔴 solution
326 Power of Three 🟢 solution
328 Odd Even Linked List 🟡 solution
342 Power of Four 🟢 solution
344 Reverse String 🟢 solution
367 Valid Perfect Square 🟢 solution
374 Guess Number Higher or Lower 🟢 solution
383 Ransom Note 🟢 solution
387 First Unique Character in a String 🟢 solution
390 Elimination Game 🟡 solution
392 Is Subsequence 🟢 solution
394 Decode String 🟡 solution
404 Sum of Left Leaves 🟢 solution
437 Path Sum III 🟡 solution
442 Find All Duplicates in an Array 🟡 solution
443 String Compression 🟡 solution
445 Add Two Numbers II 🟡 solution
450 Delete Node in a BST 🟡 solution
451 Sort Characters By Frequency 🟡 solution
486 Predict The Winner 🟡 solution
496 Next Greater Element I 🟢 solution
506 Relative Ranks 🟢 solution
509 Fibonacci Number 🟢 solution
513 Find Bottom Left Tree Value 🟡 solution
515 Find Largest Value in Each Tree Row 🟡 solution
520 Detect Capital 🟢 solution
538 Convert BST to Greater Tree 🟡 solution
543 Diameter of Binary Tree 🟢 solution
557 Reverse Words in a String III 🟢 solution
567 Permutation in String 🟡 solution
617 Merge Two Binary Trees 🟢 solution
622 Design Circular Queue 🟡 solution
632 Smallest Range Covering Elements from K Lists 🔴 solution
637 Average of Levels in Binary Tree 🟢 solution
653 Two Sum IV - Input is a BST 🟢 solution
654 Maximum Binary Tree 🟡 solution
700 Search in a Binary Search Tree 🟢 solution
701 Insert into a Binary Search Tree 🟡 solution
704 Binary Search 🟢 solution
733 Flood Fill 🟢 solution
739 Daily Temperatures 🟡 solution
740 Delete and Earn 🟡 solution
779 K-th Symbol In Grammar 🟡 solution
790 Domino and Tromino Tiling 🟡 solution
797 All Paths From Source to Target 🟡 solution
832 Flipping an Image 🟢 solution
834 Sum of Distances in Tree 🔴 solution
841 Keys and Rooms 🟡 solution
844 Backspace String Compare 🟢 solution
852 Peak Index in a Mountain Array 🟡 solution
863 All Nodes Distance K in Binary Tree 🟡 solution
872 Leaf-Similar Trees 🟢 solution
876 Middle of the Linked List 🟢 solution
886 Possible Bipartition 🟡 solution
921 Minimum Add to Make Parentheses Valid 🟡 solution
931 Minimum Falling Path Sum 🟡 solution
938 Range Sum of BST 🟢 solution
958 Check Completeness of a Binary Tree 🟡 solution
977 Squares of a Sorted Array 🟢 solution
980 Unique Paths III 🔴 solution
997 Find the Town Judge 🟢 solution
1008 Construct Binary Search Tree from Preorder Traversal 🟡 solution
1009 Complement of Base 10 Integer 🟢 solution
1026 Maximum Difference Between Node and Ancestor 🟡 solution
1038 Binary Search Tree to Greater Sum Tree 🟡 solution
1047 Remove All Adjacent Duplicates In String 🟢 solution
1143 Longest Common Subsequence 🟡 solution
1047 Remove All Adjacent Duplicates In String 🟢 solution
1207 Unique Number of Occurrences 🟢 solution
1281 Subtract the Product and Sum of Digits of an Integer 🟢 solution
1290 Convert Binary Number in a Linked List to Integer 🟢 solution
1339 Maximum Product of Splitted Binary Tree 🟡 solution
1325 Delete Leaves With a Given Value 🟡 solution
1342 Number of Steps to Reduce a Number to Zero 🟢 solution
1373 Maximum Sum BST in Binary Tree 🔴 solution
1382 Balance a Binary Search Tree 🟡 solution
1448 Count Good Nodes in Binary Tree 🟡 solution
1491 Average Salary Excluding the Minimum and Maximum Salary 🟢 solution
1523 Count Odd Numbers in an Interval Range 🟢 solution
1544 Make The String Great 🟢 solution
1572 Matrix Diagonal Sum 🟢 solution
1655 Distribute Repeating Integers 🔴 solution
1657 Determine if Two Strings Are Close 🟡 solution
1672 Richest Customer Wealth 🟢 solution
1704 Determine if String Halves Are Alike 🟢 solution
1723 Find Minimum Time to Finish All Jobs 🔴 solution
1752 Check if Array Is Sorted and Rotated 🟢 solution
1791 Find Center of Star Graph 🟢 solution
1823 Find the Winner of the Circular Game 🟡 solution
1823 Single-Threaded CPU 🟡 solution
1863 Sum of All Subset XOR Totals 🟢 solution
1910 Remove All Occurrences of a Substring 🟡 solution
1962 Remove Stones to Minimize the Total 🟡 solution
1963 Minimum Number of Swaps to Make the String Balanced 🟡 solution
1971 Find if Path Exists in Graph 🟢 solution
2095 Delete the Middle Node of a Linked List 🟡 solution
2169 Count Operations to Obtain Zero 🟢 solution
2181 Merge Nodes in Between Zeros 🟡 solution
2256 Minimum Average Difference 🟡 solution
2265 Count Nodes Equal to Average of Subtree 🟡 solution
2279 Maximum Bags With Full Capacity of Rocks 🟡 solution
2367 Number of Arithmetic Triplets 🟢 solution
2385 Amount of Time for Binary Tree to Be Infected 🟡 solution
2389 Longest Subsequence With Limited Sum 🟢 solution
2469 Convert the Temperature 🟢 solution
2472 Maximum Number of Non-overlapping Palindrome Substrings 🟡 solution
2485 Find the Pivot Integer 🟢 solution
2486 Append Characters to String to Make Subsequence 🟡 solution
2487 Remove Nodes From Linked List 🟡 solution
2490 Circular Sentence 🟢 solution
2491 Divide Players Into Teams of Equal Skill 🟡 solution
2496 Maximum Value of a String in an Array 🟢 solution
2500 Delete Greatest Value in Each Row 🟢 solution
2501 Longest Square Streak in an Array 🟡 solution
2502 Design Memory Allocator 🟡 solution
2506 Count Pairs Of Similar Strings 🟢 solution
2507 Smallest Value After Replacing With Sum of Prime Factors 🟡 solution
2515 Shortest Distance to Target String in a Circular Array 🟢 solution
2520 Count the Digits That Divide a Number 🟢 solution
2521 Distinct Prime Factors of Product of Array 🟡 solution
2523 Closest Prime Numbers in Range 🟡 solution

Contributors

Sahil-k
Sahil K.

💬
Aaryan-C
Aaryan Chaudhari

💬
Nirupama
Nirupama R.

💬
Shashank B
SHashank B.

💬
Yash Londhe
Yash L.

💬