Tip 1: Complete 500 high-quality questions.
Tip 2: Include several substantial projects on your resume.
Tip 1: Include projects on your resume.
Tip 2: Avoid fabricating information on your resume.



The width of each bar is the same and is equal to 1.
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].
Output: 10
Explanation: Refer to the image for better comprehension:

You don't need to print anything. It has already been taken care of. Just implement the given function.
def trapRainWater(arr):
n = len(arr)
if n <= 2:
return 0
left, right = 0, n - 1
left_max, right_max = 0, 0
result = 0
while left < right:
if arr[left] < arr[right]:
if arr[left] >= left_max:
left_max = arr[left]
else:
result += left_max - arr[left]
left += 1
else:
if arr[right] >= right_max:
right_max = arr[right]
else:
result += right_max - arr[right]
right -= 1
return result
# Example usage:
elevation_map = [0,1,0,2,1,0,1,3,2,1,2,1]
print(trapRainWater(elevation_map)) # Output: 6



Conditions for valid parentheses:
1. All open brackets must be closed by the closing brackets.
2. Open brackets must be closed in the correct order.
()()()() is a valid parentheses.
)()()( is not a valid parentheses.
Based on Stack



A string is said to be palindrome if the reverse of the string is the same as the actual string. For example, “abba” is a palindrome, but “abbc” is not a palindrome.



1. Every train will depart on the same day and the departure time will always be greater than the arrival time. For example, A train with arrival time 2240 and departure time 1930 is not possible.
2. Time will be given in 24H format and colons will be omitted for convenience. For example, 9:05AM will be given as "905", or 9:10PM will be given as "2110".
3. Also, there will be no leading zeroes in the given times. For example, 12:10AM will be given as “10” and not as “0010”.
Our task is to find the minimum number of platforms required for the railway station so that no train needs to wait.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?