This repository contains my solutions to LeetCode problems.
Note: The solutions are written in JavaScript
Feel free to browse the solutions and explanations for each problem. You can clone this repository to your local machine to access the code and run it as needed.
Note: Contributions and feedback are welcome!
- Print 2D Array
- Print Multi Dimensional Array
- Diagonal Traverse
- Spiral Matrix
- Pascal Triangle
- Matrix Diagonal Sum
- Running Sum Of 1d Array
- Richest Customer Wealth
- Max Consecutive Ones
- Even Number Of Digits
- Squares Of A Sorted Array
- Duplicate Zeros
- Merge Sorted Array
- Delete Element By Index
- Remove Element
- Remove Duplicates From Sorted Array
- Check If N And Its Double Exist
- Valid Mountain Array
- Replace Elements With Greatest Element On Right Side
- Two Pointer Technique
- Move Zeroes
- Sort Array By Parity
- Height Checker
- Third Maximum Number
- Find All Numbers Disappeared In An Array
- Find Pivot Index
- Largest Number At Least Twice Of Others
- Plus One
- Array Partition I
- Two Sum II - Input Array Is Sorted
- Minimum Size Subarray Sum
- Rotate Array
- Pascal Triangle II
- Sort an Array (Merge Sort)
- Duplicate Zeros
- Concatenation Of Array
- Build Array From Permutation
- Shuffle the Array
- Number of Employees Who Met the Target
- Kids With the Greatest Number of Candies
- Sum of Values at Indices With K Set Bits
- Decode XORed Array
- Left and Right Sum Differences
- Create Target Array in the Given Order
- Minimum Operations to Exceed Threshold Value I
- Truncate Sentence
- Shuffle String
- Difference Between Element Sum and Digit Sum of an Array
- Find First Palindromic String in the Array
- Count Number of Pairs With Absolute Difference K
- Count the Number of Consistent Strings
- Find the Highest Altitude
- Sum of All Odd Length Subarrays
- Check if a String Is an Acronym of Words
- Unique Morse Code Words
- Find Common Elements Between Two Arrays
- Minimum Time Visiting All Points
- Subarrays Distinct Element Sum of Squares I
- Flipping an Image
- Find the Integer Added to Array I
- Count Good Triplets
- Find Maximum Number of String Pairs
- Count Tested Devices After Test Operations
- Sum of Squares of Special Elements
- Sort the People
- Destination City
- Count Equal and Divisible Pairs in an Array
- Separate the Digits in an Array
- Count Elements With Maximum Frequency
- Find the Difference of Two Arrays
- Number Of Rectangles That Can Form The Largest Square
- Sort Integers by The Number of 1 Bits
- Binary Search Template I
- Binary Search Template II
- Binary Search Template II
- Recursive Binary Search
- Search Insert Position
- Binary Search
- Sqrt(x)
- Guess Number Higher Or Lower
- Search in Rotated Sorted Array
- First Bad Version
- Find Peak Element
- Find Minimum In Rotated Sorted Array
- Find Minimum In Rotated Sorted Array II
- Search For A Range
- Find K Closest Elements
- Pow(x, n)
- Valid Perfect Square
- Find Smallest Letter Greater Than Target
- Count Negative Numbers in a Sorted Matrix
- Find Target Indices After Sorting Array
- Longest Subsequence With Limited Sum
- Maximum Count of Positive Integer and Negative Integer
- Find the Distance Value Between Two Arrays
- Missing Number
- Count Complete Tree Nodes
- Recyclable And Low Fat Products
- Find Total Time Spent By Each Employee
- Daily Leads And Partners
- Number of Unique Subjects Taught by Each Teacher
- Rearrange Products Table
- Invalid Tweets
- Bank Account Summary II
- Swap Salary
- Replace Employee ID With The Unique Identifier
- Product Sales Analysis I
- Reformat Department Table
- Range Sum of BST
- Find a Corresponding Node of a Binary Tree in a Clone of That Tree
- Merge Two Binary Trees
- Increasing Order Search Tree
- Sum of Root To Leaf Binary Numbers
- Fibonacci Number
- Counting Bits
- Divisor Game
- Min Cost Climbing Stairs
- N-th Tribonacci Number
- Is Subsequence
- Maximum Odd Binary Number
- Maximum 69 Number
- Maximum Sum With Exactly K Elements
- Lexicographically Smallest Palindrome
- Minimum Operations to Make the Array Increasing
- DI String Match
- Minimum Time to Type Word Using Special Typewriter
- Two Sum
- Ransom Note
- Design Hash Set
- Design Hash Map
- Find Duplicates By Hash Set
- Contains Duplicate
- Single Number
- Intersection Of Two Arrays
- Happy Number
- Isomorphic Strings
- Minimum Index Sum Of Two Lists
- First Unique Character In A String
- Intersection Of Two Arrays II
- Contains Duplicate II
- Group Anagrams
- Valid Sudoku
- Find Duplicate Subtrees
- Jewels And Stones
- Longest Substring Without Repeating Characters
- 4Sum II
- Top K Frequent Elements
- Insert Delete GetRandom O(1)
- Number of Good Pairs
- How Many Numbers Are Smaller Than the Current Number
- Decode the Message
- Number of Arithmetic Triplets
- Design Linked List
- Design Doubly Linked List
- Middle Of Linked List
- Linked List Cycle
- Linked List Cycle II
- Intersection Of Two Linked Lists
- Remove Nth Node From End Of List
- Reverse Linked List
- Remove Linked List Elements
- Odd Even Linked List
- Palindrome Linked List
- Merge Two Sorted Lists
- Add Two Numbers
- Print Multilevel Linked List
- Flatten Multilevel Linked List
- Copy List With Random Pointer
- Rotate List
- Number Of Steps To Reduce A Number To Zero
- Find the Maximum Achievable Number
- Convert The Temperature
- Divisible and Non-divisible Sums Difference
- Smallest Even Multiple
- Subtract the Product and Sum of Digits of an Integer
- Minimum Sum of Four Digit Number After Splitting Digits
- Design Circular Queue
- Number of Islands
- Open The Lock
- Perfect Squares
- Queue Technique Template
- Implement Queue Using Stacks
- Fibonacci Number
- Print Reverse
- Reverse String
- Swap Nodes In Pairs
- Reverse Linked List
- Search In A Binary Search Tree
- Pascal Triangle II
- Climbing Stairs
- Maximum Depth Of Binary Tree
- Merge Two Sorted Lists
- K-th Symbol In Grammar
- Unique Binary Search Trees II
- Search a 2D Matrix II
- N Queens II
- Sudoku Solver
- Combinations
- Same Tree
- Generate Parentheses
- Largest Rectangle In Histogram
- Permutations
- Letter Combinations of a Phone Number
- The Skyline Problem
- Widest Vertical Area Between Two Points Containing No Points
- Count Pairs Whose Sum is Less than Target
- Minimum Number Game
- Sorting the Sentence
- Maximum Product Difference Between Two Pairs
- Maximum Product of Two Elements in an Array
- Minimum Number of Moves to Seat Everyone
- Design Stack
- Min Stack
- Valid Parentheses
- Daily Temperatures
- Evaluate Reverse Polish Notation
- Clone Graph
- Depth First Search Template II
- Target Sum
- Implement Stack Using Queues
- Decode String
- Flood Fill
- Keys And Rooms
- Add Binary
- Implement StrStr
- Longest Common Prefix
- Reverse String
- Reverse Words In A String
- Reverse Words In A String III
- Defanging An IP Address
- Final Value Of Variable After Performing Operations
- Goal Parser Interpretation
- Maximum Number of Words Found in Sentences
- Find Words Containing Character
- Split A String In Balanced Strings
- Check If Two String Arrays Are Equivalent
- Count Items Matching A Rule
- Length of Last Word
- Invert Binary Tree
- Binary Tree Inorder Traversal
- Binary Tree Preorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Level Order Traversal
- N-ary Tree Preorder Traversal
- N-ary Tree Postorder Traversal
- N-ary Tree Level Order Traversal
- Search In A Binary Search Tree
- Insert Into A Binary Search Tree
- Delete Node In A Binary Search Tree
- Root Equal Sum Of Children
- Maximum Depth Of Binary Tree
- Symmetric Tree
- Path Sum
- Construct Binary Tree From Inorder And Postorder Traversal
- Construct Binary Tree From Preorder And Inorder Traversal
- Populating Next Right Pointers in Each Node
- Populating Next Right Pointers in Each Node II
- Lowest Common Ancestor of a Binary Tree
- Serialize And Deserialize Binary Tree
- Maximum Depth Of N-ary Tree
- Validate Binary Search Tree
- Binary Search Tree Iterator
- Kth Largest Element In A Stream
- Lowest Common Ancestor of a Binary Search Tree
- Contains Duplicate III
- Balanced Binary Tree
- Convert Sorted Array To Binary Search Tree
- Diameter Of Binary Treee