SOLUTIONS
LEETCODE.

Analysis and solutions for algorithmic problems.

Problem Difficulty Complexity Date
0220 Contains Duplicate III Hard T: O(N) where N is the length of the array / S: O(min(N, indexDiff)) for the bucket map Mar 2026
0224 Basic Calculator Hard T: O(N) where N is the length of the string / S: O(N) for the stack in the worst case of nested parentheses Mar 2026
0233 Number of Digit One Hard T: O(log N) where N is the input number / S: O(1) constant extra space Mar 2026
0239 Sliding Window Maximum Hard T: O(N) where N is the length of the array / S: O(K) where K is the window size Mar 2026
0273 Integer to English Words Hard T: O(1) since the input is bounded by 2^31 - 1 (at most 10 digits) / S: O(1) for the same reason Mar 2026
0282 Expression Add Operators Hard T: O(N * 4^N) where N is the length of the string / S: O(N) for the recursion depth Mar 2026
0295 Find Median from Data Stream Hard T: O(log N) per insertion, O(1) per median query / S: O(N) where N is the total number of inserted elements Mar 2026
0297 Serialize and Deserialize Binary Tree Hard T: O(N) where N is the number of nodes in the tree / S: O(N) for storing the serialized string and the recursion stack Mar 2026
0301 Remove Invalid Parentheses Hard T: O(2^N) where N is the length of the string / S: O(N) for the recursion depth and the expression being built Mar 2026
0312 Burst Balloons Hard T: O(N^3) / S: O(N^2) Mar 2026
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