π A collection of LeetCode problems Iβve solved. π‘ Solutions with explanations to understand the approach. π Organized by difficulty and problem type. π― Practicing daily to get better at algorithms and data structures. π Feel free to explore, learn, and suggest improvements!
- Solved LeetCode Problem 15: 3Sum
- Approach: Two-pointer technique
- Handled edge cases:
- Array/List size less than 3
- Duplicate elements
- Solved LeetCode Problem 16: 3Sumclosest
- Approach: Two-pointer technique
- Handled edge cases:
- Array/List size less than 3
- Duplicate elements
- Updating the closest_sum when there is a best difference.
- Solved LeetCode Problem 18: 4Sum
- Approach: Two-pointer technique
- Handled edge cases:
- Array/List size less than 4
- Duplicate elements
- Updating the two pointers and storing valid quadruplets.
- Solved LeetCode Problem 11: Container with most water
- Approach: Two pointer approach
- Handled edge cases:
- Computing max_area based on minimum height from the left or right.
- Updating the two pointers and storing valid max_area.
- Solved LeetCode Problem 31: Finding the next permutation
- Approach: Two pointers and swapping
- Handled edge cases:
- Finding first drop in the list.
- Swapping the elements.
- Reversing the right part of list.
- Solved LeetCode Problem 35: Search insert position
- Approach: Binary Search
- Handled edge cases:
- Finding the element based mid value.
- The last value of left index the expected index.
- Solved LeetCode Problem 3: Finding longest substring without repeating character
- Approach: Sliding Window
- Handled edge cases:
- Finding the longest substring using sliding window and HashTable.
- The shrinking or expandng window using two pointers.
- Solved LeetCode Problem 49: Finding anagrams
- Approach: Sorting and Hashtable(dictionary)
- Handled edge cases:
- Using a defaultdict() from collections to create a dictionary of values stored as list.
- Finding the key for dictionary using join() and sorted() methods.
- Returning the list of values.
- Solved LeetCode Problem 33: Searching in sorted and rotated array
- Approach: Binary search
- Handled edge cases:
- Finding which half is sorted.
- Finding which pointer to move(left or move).
- Returning -1 if the element is not found.