Skip to content

Instantly share code, notes, and snippets.

@ikouchiha47
Last active June 5, 2024 06:49
Show Gist options
  • Save ikouchiha47/6b2ef62b913c722db19232fe173403fb to your computer and use it in GitHub Desktop.
Save ikouchiha47/6b2ef62b913c722db19232fe173403fb to your computer and use it in GitHub Desktop.
Algorithm Problem Statement Classification

Basic Binary Search

  1. Binary Search
  2. Search Insert Position
  3. Guess Number Higher or Lower
  4. Find Peak Element
  5. Find Smallest Letter Greater Than Target
  6. Search in a Sorted Array of Unknown Size
  7. Fixed Point
  8. Find the Index of the Large Integer

Rotated Sorted Array

  1. Search in Rotated Sorted Array
  2. Search in Rotated Sorted Array II
  3. Find Minimum in Rotated Sorted Array
  4. Find Minimum in Rotated Sorted Array II

Search in a Matrix

  1. Search a 2D Matrix
  2. Search a 2D Matrix II
  3. Kth Smallest Element in a Sorted Matrix
  4. Find Kth Smallest Sum of a Matrix With Sorted Rows
  5. Median of a Row Wise Sorted Matrix

Range Queries and Sums

  1. Minimum Size Subarray Sum
  2. Count of Range Sum
  3. Range Sum of Sorted Subarray Sums
  4. Sum of Mutated Array Closest to Target
  5. Sum of Scores of Built Strings

Position and Index Search

  1. Find First and Last Position of Element in Sorted Array
  2. Find K Closest Elements
  3. Find Right Interval
  4. Find K-th Smallest Pair Distance
  5. Find Peak Element II

Special Patterns and Sequences

  1. Longest Increasing Subsequence
  2. 132 Pattern
  3. Longest Arithmetic Subsequence
  4. Longest Duplicate Substring
  5. Longest Common Subpath
  6. Longest Square Streak in an Array
  7. Find Longest Equal Subarray
  8. Find Longest Special Substring That Occurs Thrice II
  9. Find Longest Special Substring That Occurs Thrice I

Handling Intervals and Events

  1. Data Stream as Disjoint Intervals
  2. My Calendar I
  3. My Calendar II
  4. My Calendar III
  5. Design Hit Counter
  6. Booking Concert Tickets in Groups

Kth and Nth Elements

  1. Kth Smallest Element in a Sorted Matrix
  2. Kth Smallest Number in Multiplication Table
  3. Kth Smallest Prime Fraction
  4. Kth Smallest Product of Two Sorted Arrays
  5. Kth Missing Positive Number
  6. Kth Smallest Subarray Sum
  7. Kth Ancestor of a Tree Node
  8. Kth Smallest Amount With Single Denomination Combination

Closest and Approximate Search

  1. Closest Binary Search Tree Value
  2. Closest Room
  3. Find a Value of a Mysterious Function Closest to Target
  4. Closest Binary Search Tree Value II

Number Operations

  1. Sqrt(x)
  2. Valid Perfect Square
  3. Nth Digit
  4. Nth Magical Number
  5. Prime Subtraction Operation

Minimum and Maximum Search

  1. Minimize Max Distance to Gas Station
  2. Max Sum of Rectangle No Larger Than K
  3. Maximum Average Subarray II
  4. Maximum Length of Repeated Subarray
  5. Maximum Distance Between a Pair of Values
  6. Minimum Speed to Arrive on Time
  7. Minimum Space Wasted From Packaging
  8. Minimum Number of Days to Make m Bouquets
  9. Maximum Number of Events That Can Be Attended II
  10. Maximum Sum Queries
  11. Maximum Value at a Given Index in a Bounded Array
  12. Maximize the Minimum Powered City
  13. Maximum Coins Heroes Can Collect
  14. Minimum Cost to Make Array Equal
  15. Maximize Win From Two Segments
  16. Maximize the Profit as the Salesman

Subarray and Subsequence Problems

  1. Two Sum II - Input Array Is Sorted
  2. Count of Smaller Numbers After Self
  3. Subsequence With the Minimum Score
  4. Count of Range Sum
  5. Count Pairs Whose Sum is Less than Target
  6. Count Negative Numbers in a Sorted Matrix
  7. Find Two Non-overlapping Sub-arrays Each With Target Sum

Array Manipulation and Special Conditions

  1. Smallest Rectangle Enclosing Black Pixels
  2. Smallest Good Base
  3. Russian Doll Envelopes
  4. Avoid Flood in The City
  5. Intersection of Two Arrays
  6. Intersection of Two Arrays II
  7. Find Positive Integer Solution for a Given Equation
  8. Maximum Strictly Increasing Cells in a Matrix
  9. Minimum Array Length After Pair Removals
  10. Equalize Strings by Adding or Removing Characters at Ends

Scheduling and Planning

  1. Maximum Profit in Job Scheduling
  2. Minimum Time to Complete All Tasks
  3. Find the Latest Group of Size M
  4. Minimum Number of Removals to Make Mountain Array

Others

  1. H-Index II
  2. First Bad Version
  3. Find the Duplicate Number
  4. Missing Number
  5. Heaters
  6. Reach a Number
  7. Peak Index in a Mountain Array
  8. Shortest Subarray with Sum at Least K
  9. Random Pick with Blacklist
  10. Koko Eating Bananas
  11. Leftmost Column with at Least a One
  12. Maximum Font to Fit a Sentence in a Screen
  13. Search Suggestions System
  14. Valid Triangle Number
  15. Sum of Square Numbers
  16. Friends Of Appropriate Ages
  17. Most Profit Assigning Work
  18. Fair Candy Swap
  19. Numbers At Most N Given Digit Set
  20. Online Election
  21. Time Based Key-Value Store
  22. Max Consecutive Ones III
  23. Capacity To Ship Packages Within D Days
  24. Missing Element in Sorted Array
  25. Find Smallest Common Element in All Rows
  26. Intersection of Three Sorted Arrays
  27. Two Sum BSTs
  28. Find in Mountain Array
  29. Divide Chocolate
  30. Snapshot Array
  31. Online Majority Element In Subarray
  32. Compare Strings by Frequency of the Smallest Character
  33. Make Array Strictly Increasing
  34. Range Frequency Queries
  35. Minimum Garden Perimeter to Collect Enough Apples
  36. Ugly Number III
  37. Get Equal Substrings Within Budget
  38. Sum of Floored Pairs
  39. Maximum Candies Allocated to K Children
// url: https://leetcode.com/tag/binary-search/
JSON.stringify(Array.from($$(".title-cell__ZGos a")).map(el => el.innerText))
// Copy and put this is something like Phi3. And Prompt Template:
// Task: Group the following binary search problems by similarity and classify them into appropriate categories.
// Problems: {problems_json}
// With a react Agent
//Task: Group the following binary search problems by similarity and classify them into appropriate categories, ensuring each category contains at most 10-20 problems.
//Step-by-Step Instructions:
// 1.Read the List: Carefully read the list of binary search problems.
// 2.Identify Similarities: Identify key similarities among the problems, such as problem type, data structure involved, or the nature of the binary search.
// 3.Define Categories: Define clear and distinct categories based on the identified similarities.
// 4.Group Problems: Group problems into the defined categories, ensuring each category contains at most 10-20 problems. If a category exceeds this limit, split it into smaller subcategories.
// 5.Review and Refine: Review the groups and categories to ensure accuracy and coherence, making any necessary adjustments.
// Problems:
// {PROBLEMS_LIST}
// API: Fucked up with CORS
/*
fetch("https://leetcode.com/problems/tag-data/question-tags/binary-search/", {
"headers": {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0",
"Accept-Language": "en-US,en;q=0.5",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin"
},
"referrer": "https://leetcode.com/tag/binary-search/",
"method": "GET",
}).then(json => json.json()).then(data => data.questions.map(q => q.title)).then(txt => console.log(JSON.stringify(txt)))
*/

After analyzing the list of Two Pointers problems, I've identified the following categories:

1. Palindromic Substrings

  • Longest Palindromic Substring
  • Valid Palindrome
  • Valid Palindrome II
  • Palindromic Substrings
  • Find First Palindromic String in the Array

2. Linked List Operations

  • Remove Nth Node From End of List
  • Rotate List
  • Sort List
  • Reverse Words in a String
  • Middle of the Linked List
  • Delete the Middle Node of a Linked List
  • Merge Two 2D Arrays by Summing Values
  • Print Immutable Linked List in Reverse

3. Sorting and Ordering

  • Remove Duplicates from Sorted Array
  • Remove Duplicates from Sorted Array II
  • Sort Colors
  • Sort Transformed Array
  • Sort Array By Parity
  • Sort Array By Parity II
  • Pancake Sorting

4. Two Pointer Problems

  • 2Sum
  • 3Sum
  • 3Sum Closest
  • 4Sum
  • 3Sum Smaller
  • Two Sum Less Than K
  • Two Sum IV - Input is a BST
  • Find K-th Smallest Pair Distance

5. Array Operations

  • Container With Most Water
  • Trapping Rain Water
  • Longest Mountain in Array
  • Shortest Unsorted Continuous Subarray
  • Number of Ways Where Square of Number Is Equal to Product of Two Numbers
  • Dot Product of Two Sparse Vectors
  • Split Two Strings to Make Palindrome

6. String Manipulation

  • Reverse Words in a String
  • Reverse Words in a String II
  • Reverse Words in a String III
  • Swapping Nodes in a Linked List
  • Permutation in String
  • Shortest Way to Form String

7. Miscellaneous

  • Meeting Scheduler
  • Duplicate Zeros
  • Lowest Common Ancestor of a Binary Tree III
  • Max Number of K-Sum Pairs
  • Checking Existence of Edge Length Limited Paths
  • Ways to Split Array Into Three Subarrays
  • Minimum Length of String After Deleting Similar Ends

Please let me know if you have any further questions or need help with answering specific user queries based on these problem statements!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment