Tuesday 24 August 2021

trapping-rain-water

 https://leetcode.com/problems/trapping-rain-water/


brute-force 

water at any x = min( max_left_of_x, max_right_of_x) - height_of_x

two-pointer solution 

when keeping 

1) 

  • p_start, at 0
  • p_end at 11 [length-1] of array
  • check, 
    • p_start height is less. => 0
    • p_end height is less => 1
      • answer: p_start => 0 is lesser
  • height at 0 is less
  • p_start becomes our p_current pointer.
  • with respect to p_current
  • we check 
    • max_left
    • max_right  
  1. whenever we check which is lesser p_start, p_end, we are actually evaluating  min(p_start, p_end)
  2. by checking min, of two, we get the level, which water can be filled.

formula

 

Level => check min of p_start, p_end 

current_level = min(p_start, p_end)

if p_start is less, we start from left, and 

  • make max_left = height_at_p_start 
  • make max_right = height_at_p_end
  • we consider level = max_left 
  •  



***incomplete post


 

 

 



1 comment:

  1. Harrah's Casino Resort, Phoenix - JTM Hub
    › rooms-and-suites › harrah-s 경주 출장마사지 › rooms-and-suites › harrahs Harrah's Casino Resort and Ak-Chin Hotels. Harrah's Ak-Chin Casino. 문경 출장마사지 639. (207) 641-8125 · Call Now · More Info. Hours, Accepts Credit Cards, Attire, 통영 출장안마 Wi-Fi. Rating: 4.5 2,843 reviews Price range: $ (Based on Average 안산 출장안마 Nightly Rates for a Standard Room from our Partners) What are some of the property amenities at Harrah's Ak-Chin Casino Resort? What food & drink options are available at Harrah's 양주 출장마사지 Ak-Chin Casino Resort?

    ReplyDelete