Categorygithub.com/shuaibkhan786/dsa
repository
0.0.0-20241015114154-1424ba02bff0
Repository: https://github.com/shuaibkhan786/dsa.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

DESCRIPTION

Just a repo me practising DSA problems I used neetcode roadmap

PROBLEMS (Arrays and Hashing)

  1. duplicate in array (set) mySolution
  2. is Anagram (hmap, store character count) mySolution
  3. two sums (hmap, key = ele, value = index, x + y = target i,e x = target - y) mySolution
  4. k most frequent element (hmap , key = num, value = frequency, sorted bucket algo) mySolution
  5. String Encode and Decode (attached length of string before actual string) mySolution
  6. Products of Array Discluding Self (maintained product of left and right of an element) mySolution
  7. longest consecutive sequence (set , if num - 1 is not in the set then num is the new sequence) mySolution

PROBLEMS (Two Pointers)

  1. is palindrome (compare two pointer one from start and one from end, skip if the byte/character is not alphanumeric) mySolution
  2. Two Sum II - Input Array Is Sorted (array is sorted is ASC, left and right pointers) mySolution
  3. Three Integer Sum (sort the array, positive sum cant be zero, impelement two sum(two pointer) logic in the inner loop) mySolution
  4. 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)

  1. Validate Parentheses mySolution
  2. Minimum Stack (maintained a minimum and normal stack, used minimum stack to retrive the minimum value of the stack) mySolution
  3. Evaluate Reverse Polish Notation mySolution
  4. Daily Temperatures (used stack to store the index of an temperatures, just start from reverse and think) mySolution

PROBLEMS (Binary Search)

  1. Binary Search mySolution
  2. Search 2D Matrix (find potential row by doing BS on first column and again do BS on that potential row) mySolution
  3. 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
  4. Find Minimum in Rotated Sorted Array (min elemnet will be always less than left and right) mySolution
  5. 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
  6. Time Based Key-Value Store (since set timestamp is in increasing order, do BS) mySolution

PROBLEMS (Window Sliding)

  1. Maximum Average Subarray I (subtract the previous ele in left pointer and add the new element to the previous sum) mySolution
  2. Buy and Sell Crypto (dynamic size window) mySolution
  3. Longest Substring Without Duplicates (dynamic size window and set for checking repeated character) mySolution
  4. 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
  5. Sliding Window Maximum (monotonic queue) mySolution

PROBLEMS (Link List)

  1. Reverse a singly linked list mySolution
  2. Merge Two sorted singly linked list (used two pointer and apply the same logic of merging two sorted array) mySolution
  3. Reorder singly linked list (midpoint, reversed second half, merged alternately) mySolution
  4. 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
  5. Add Two Numbers mySolution
  6. Linked list cycle detection mySolution
  7. Find the duplicate (array problem but need slow and fast pointer used in Linked List) mySolution