SOLUTIONS
LEETCODE.

Hard difficulty analysis and solutions.

Problem Difficulty Complexity Date
0315 Count of Smaller Numbers After Self Hard T: O(N log N) where N is the length of the array / S: O(N) for the temporary merge buffer and index tracking Mar 2026
0321 Create Maximum Number Hard T: O(K * (M + N)) where M and N are the lengths of the two arrays / S: O(M + N) Mar 2026
0327 Count of Range Sum Hard T: O(N log N) where N is the length of the array / S: O(N) for the prefix sum array and the merge buffer Mar 2026
0329 Longest Increasing Path in a Matrix Hard T: O(M * N) where M and N are the dimensions of the matrix / S: O(M * N) Mar 2026
0330 Patching Array Hard T: O(M + log N) where M is the length of nums and N is the target / S: O(1) Mar 2026
0332 Reconstruct Itinerary Hard T: O(E log E) where E is the number of tickets / S: O(E) Mar 2026
0335 Self Crossing Hard T: O(n) where n is the length of the distance array / S: O(1) Mar 2026
0336 Palindrome Pairs Hard T: O(N * K^2) / S: O(N * K) Mar 2026
0352 Data Stream as Disjoint Intervals Hard T: O(log N) per addNum, O(N) per getIntervals, where N is the number of intervals / S: O(N) Mar 2026
0354 Russian Doll Envelopes Hard T: O(N log N) where N is the number of envelopes / S: O(N) Mar 2026
0363 Max Sum of Rectangle No Larger Than K Hard T: O(M^2 * N * log N) where M is the number of rows and N is the number of columns / S: O(N) Mar 2026
0381 Insert Delete GetRandom O(1) Duplicates Allowed Hard T: O(1) amortized per insert, remove, and getRandom / S: O(N), where N is the total number of elements in the collection Mar 2026
0391 Perfect Rectangle Hard T: O(N) where N is the number of rectangles / S: O(N) Mar 2026
0403 Frog Jump Hard T: O(N^2) where N is the number of stones / S: O(N^2) Mar 2026
0407 Trapping Rain Water II Hard T: O(M * N * log(M * N)) where M and N are the dimensions of the matrix / S: O(M * N) Mar 2026
0410 Split Array Largest Sum Hard T: O(N * log(S)) where N is the length of the array and S is the sum of all elements / S: O(1) Mar 2026
0420 Strong Password Checker Hard T: O(N) where N is the length of the password / S: O(N) for storing the repeating sequences Mar 2026
0432 All O`one Data Structure Hard T: O(1) per inc, dec, getMaxKey, and getMinKey operation / S: O(N), where N is the number of distinct keys in the structure Mar 2026
0440 K-th Smallest in Lexicographical Order Hard T: O(log(n)^2), where n is the upper bound of the range / S: O(1) Mar 2026
0446 Arithmetic Slices II - Subsequence Hard T: O(N^2), where N is the length of the array / S: O(N^2), for the hash maps stored at each index Mar 2026