Skip to content

Latest commit

 

History

History
77 lines (74 loc) · 8.96 KB

hard.md

File metadata and controls

77 lines (74 loc) · 8.96 KB

LeetCode Hard Problems

A collection of LeetCode Hard difficulty problems solved with step-by-step explanations, pattern categorization, and optimized source code.

Problem Index

# Problem Pattern Language Time Space
4 Median of Two Sorted Arrays Binary Search Python O(n) O(1)
10 Regular Expression Matching Dynamic Programming JavaScript O(n) O(n)
23 Merge k Sorted Lists Two Pointers Python O(n) O(1)
25 Reverse Nodes in k-Group Two Pointers Python O(n) O(1)
30 Substring with Concatenation of All Words Sliding Window Python O(n) O(1)
32 Longest Valid Parentheses Stack & Queue Python O(n) O(n)
37 Sudoku Solver Array / General Python O(n) O(1)
41 First Missing Positive Array / General Python O(n) O(1)
42 Trapping Rain Water Array / General Python O(n) O(1)
44 Wildcard Matching Array / General Python O(n) O(1)
51 N-Queens Tree & Graph Python O(n) O(n)
52 N-Queens II Array / General Python O(n) O(1)
60 Permutation Sequence Backtracking Python O(n) O(1)
65 Valid Number Array / General Python O(n) O(1)
68 Text Justification Heap Python O(n) O(n)
76 Minimum Window Substring Sliding Window PHP O(n) O(1)
84 Largest Rectangle in Histogram Monotonic Stack TypeScript O(n) O(n)
85 Maximal Rectangle Math & Logic Python O(n) O(1)
115 Distinct Subsequences Dynamic Programming JavaScript O(n) O(n)
154 Find Minimum in Rotated Sorted Array II Binary Search C++ O(n) O(1)
185 Department Top Three Salaries Database / SQL SQL O(n) O(n)
262 Trips and Users Database / SQL SQL O(n) O(n)
301 Remove Invalid Parentheses Stack & Queue Python O(n) O(n)
601 Human Traffic of Stadium Database / SQL SQL O(n) O(n)
940 Distinct Subsequences II Dynamic Programming JavaScript O(n) O(n)
1096 Brace Expansion II Array / General JavaScript O(n) O(1)
1301 Number of Paths with Max Score Dynamic Programming PHP O(n) O(n)
1340 Jump Game V Dynamic Programming C++ O(n) O(n)
1345 Jump Game IV Hash Map C++ O(n) O(n)
1406 Stone Game III Dynamic Programming PHP O(n) O(n)
1510 Stone Game IV Dynamic Programming TypeScript O(n) O(n)
1520 Maximum Number of Non-Overlapping Substrings Heap JavaScript O(n) O(n)
1563 Stone Game V Prefix Sum Java O(n) O(n)
1665 Minimum Initial Energy to Finish Tasks Binary Search C++ O(log n) O(1)
1840 Maximum Building Height Tree & Graph Python O(n) O(n)
1872 Stone Game VIII Prefix Sum Java O(n) O(n)
2213 Longest Substring of One Repeating Character Binary Search Java O(n) O(1)
2267 Check if There Is a Valid Parentheses String Path Stack & Queue C++ O(n) O(n)
2267 Check if There Is a Valid Parentheses String Path Stack & Queue C++ O(n) O(n)
2472 Maximum Number of Non-overlapping Palindrome Substrings Two Pointers JavaScript O(n) O(1)
2630 Memoize II Hash Map TypeScript O(n) O(n)
2650 Design Cancellable Function Array / General TypeScript O(n) O(1)
3093 Longest Common Suffix Queries Hash Map Python O(n) O(n)
3116 Kth Smallest Amount With Single Denomination Combination Backtracking Java O(n) O(1)
3161 Block Placement Queries Array / General Python O(n) O(1)
3312 Sorted GCD Pair Queries Dynamic Programming PHP O(n) O(n)
3336 Find the Number of Subsequences With Equal GCD Dynamic Programming PHP O(n) O(n)
3348 Smallest Divisible Digit Product II Math & Logic Python, TypeScript O(n) O(1)
3414 Maximum Score of Non-overlapping Intervals Heap JavaScript O(n) O(n)
3451 Find Invalid IP Addresses Database / SQL SQL O(n) O(n)
3482 Analyze Organization Hierarchy Array / General Python O(n) O(1)
3501 Maximize Active Section with Trade II Array / General PHP O(n) O(1)
3518 Smallest Palindromic Rearrangement II Tree & Graph PHP O(n) O(n)
3525 Find X Value of Array II Binary Search JavaScript O(n) O(1)
3534 Path Existence Queries in a Graph II Tree & Graph PHP O(n) O(n)
3554 Find Category Recommendation Pairs Array / General Python O(n) O(1)
3559 Number of Ways to Assign Edge Weights II Tree & Graph Python O(n) O(n)
3614 Process String with Special Operations II Tree & Graph Python O(n) O(n)
3617 Find Students with Study Spiral Pattern Database / SQL SQL O(n) O(n)
3620 Network Recovery Pathways Tree & Graph PHP O(n) O(n)
3673 Find Zombie Sessions Database / SQL SQL O(n) O(n)
3691 Maximum Total Subarray Value II Array / General Python O(n) O(1)
3699 Number of ZigZag Arrays I Hash Map PHP O(n) O(n)
3700 Number of ZigZag Arrays II Tree & Graph PHP O(n) O(n)
3734 Lexicographically Smallest Palindromic Permutation Greater Than Target Backtracking Java O(n) O(1)
3739 Count Subarrays With Majority Element II Array / General PHP O(n) O(1)
3753 Total Waviness of Numbers in Range II Array / General Python O(n) O(1)
3764 Most Common Course Pairs Database / SQL SQL O(n) O(n)
3832 Find Users with Persistent Behavior Patterns Database / SQL SQL O(n) O(n)