Solved "Trapping Rain Water" problem on LeetCode with Java and arrays.

📌 Day 12/100 – 100 Days of Code Challenge 🚀 Today’s LeetCode challenge: “Trapping Rain Water” (LeetCode #42) – one of the most popular Hard-level problems that strengthens logic building and array manipulation skills. 🔹 Approach: Used precomputed leftMax and rightMax arrays to determine how much water each bar can trap. For every index, the trapped water = min(leftMax[i], rightMax[i]) - height[i]. 🔹 Key Learnings: Improved understanding of prefix and suffix computations. Reinforced problem-solving using array-based preprocessing. Time Complexity: O(n) Space Complexity: O(n) #100DaysOfCode #LeetCode #Java #DSA #Arrays #TwoPointer #ProblemSolving #CodingJourney #DynamicProgramming #DailyChallenge

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories