SOLUTIONS
LEETCODE.

Analysis and solutions for algorithmic problems.

Problem Difficulty Complexity Date
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
0458 Poor Pigs Hard T: O(log(buckets) / log(states)), where states = (minutesToTest / minutesToDie) + 1 / S: O(1) Mar 2026
0460 LFU Cache Hard T: O(1) / S: O(N) Mar 2026
0744 Find Smallest Letter Greater Than Target Easy T: O(n) / S: O(1) Mar 2026
0840 Magic Squares In Grid Medium T: O(R * C) / S: O(1) Mar 2026
1200 Minimum Absolute Difference Easy T: O(n log n) / S: O(n) Mar 2026
1292 Maximum Side Length of a Square Medium T: O(m * n) / S: O(m * n) Mar 2026
1382 Balance a Binary Search Tree Medium T: O(n) / S: O(n) Mar 2026
1653 Minimum Deletions to Make String Balanced Medium T: O(n) / S: O(1) Mar 2026
1877 Minimize Maximum Pair Sum in Array Medium T: O(n log n) / S: O(1) Mar 2026
1895 Largest Magic Square Medium T: O(m * n * min(m, n)) / S: O(m * n) Mar 2026