repository
0.0.0-20241015114154-1424ba02bff0
Repository: https://github.com/shuaibkhan786/dsa.git
Documentation: pkg.go.dev
# README
DESCRIPTION
Just a repo me practising DSA problems I used neetcode roadmap
PROBLEMS (Arrays and Hashing)
- duplicate in array (set) mySolution
- is Anagram (hmap, store character count) mySolution
- two sums (hmap, key = ele, value = index, x + y = target i,e x = target - y) mySolution
- k most frequent element (hmap , key = num, value = frequency, sorted bucket algo) mySolution
- String Encode and Decode (attached length of string before actual string) mySolution
- Products of Array Discluding Self (maintained product of left and right of an element) mySolution
- longest consecutive sequence (set , if num - 1 is not in the set then num is the new sequence) mySolution
PROBLEMS (Two Pointers)
- is palindrome (compare two pointer one from start and one from end, skip if the byte/character is not alphanumeric) mySolution
- Two Sum II - Input Array Is Sorted (array is sorted is ASC, left and right pointers) mySolution
- Three Integer Sum (sort the array, positive sum cant be zero, impelement two sum(two pointer) logic in the inner loop) mySolution
- Maximum Water Container ( used two pointer left and right , index will be the width and element is the actual height of bar, and find the area = min(height[left], height[right]) * (right - left) ) mySolution
PROBLEMS (Stack)
- Validate Parentheses mySolution
- Minimum Stack (maintained a minimum and normal stack, used minimum stack to retrive the minimum value of the stack) mySolution
- Evaluate Reverse Polish Notation mySolution
- Daily Temperatures (used stack to store the index of an temperatures, just start from reverse and think) mySolution
PROBLEMS (Binary Search)
- Binary Search mySolution
- Search 2D Matrix (find potential row by doing BS on first column and again do BS on that potential row) mySolution
- Koko Eating Bananas (min and max speed of koko is 1 and max(piles), do that BS on that range and check againt the totaltime at that mid rate) mySolution
- Find Minimum in Rotated Sorted Array (min elemnet will be always less than left and right) mySolution
- Find Target in Rotated Sorted Array (first check target == mid, if not find the sorted and unsorted subarray and then check wether that target is fit on the sorted or unsorted subarray) mySolution
- Time Based Key-Value Store (since set timestamp is in increasing order, do BS) mySolution
PROBLEMS (Window Sliding)
- Maximum Average Subarray I (subtract the previous ele in left pointer and add the new element to the previous sum) mySolution
- Buy and Sell Crypto (dynamic size window) mySolution
- Longest Substring Without Duplicates (dynamic size window and set for checking repeated character) mySolution
- Minimum Window Substring (use left ptr to find the minimum sub string and right ptr to find that WS that contains the target sub string characters) mySolution
- Sliding Window Maximum (monotonic queue) mySolution
PROBLEMS (Link List)
- Reverse a singly linked list mySolution
- Merge Two sorted singly linked list (used two pointer and apply the same logic of merging two sorted array) mySolution
- Reorder singly linked list (midpoint, reversed second half, merged alternately) mySolution
- Remove Node From End of Linked List (first -pointer 𝑛 steps ahead and second points to the node just before the nth node we need removed, used dummy node for edge case) mySolution
- Add Two Numbers mySolution
- Linked list cycle detection mySolution
- Find the duplicate (array problem but need slow and fast pointer used in Linked List) mySolution