โฑ๏ธ Time & Space Complexity
โฑ๏ธ T.C : O(n log n)
โ Sliding window + TreeSet insert/remove & rebalancing
๐ซ S.C : O(n)
โ Two TreeSets to manage window elements
โฑ๏ธ Time & Space Complexity
โ T.C : O(n) Each number is processed in constant time (bit shifts are bounded by 32 bits).
โ S.C : O(1) (excluding output array)
โฑ๏ธTime & Space Complexity
โT.C : O(Hยฒ + Vยฒ)
H = number of horizontal fences
V = number of vertical fences
We check all pairwise distances
๐ซS.C : O(Hยฒ)
For storing all horizontal distances in a HashSet
๐ฎ๐ณ๐น LeetCode Daily Challenge
๐ LC.: 2975 โ Maximum Square Area by Removing Fences
๐ก Approach: Common Distance Matching
๐ฅ Day 767 Streak ๐ช
โค๏ธ Like | ๐ Follow @Kartscode#LeetCode#ProblemSolving#BuildInPublic#DSA