-
Notifications
You must be signed in to change notification settings - Fork 204
Added Rain water trap problem #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aastikdas
wants to merge
152
commits into
Nikhil-2002:Nikhil-2002-patch-1
Choose a base branch
from
aastikdas:main
base: Nikhil-2002-patch-1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
added shell sort code
Create largestelement.c
Create shell_sort.cpp
…st-element-in-array Added Program To Find Smallest Element in an Array
countingevenodd.c
i have added this issue please merge this
Finding the Longest Palindrome in an Array
issue resolved of removing duplicates from an array
Issue resolved of finding that arrays are disjoint or not
Calculate the sum of elements in an array
solved issue Nikhil-2002#7 .please have a look
Issue#4_reverseAnArrayAdded
Create finding_repeating_elements.c
Revert "Finding the Longest Palindrome in an Array"
…ubsequence_length Longest palindrome subsequence length
turtle game to moving turtle using arrow keys.
Created a Merge Sort Program in C
Create Palindrom_checkerwithJava.java
Create ArrayDisjoinOrNot.java
Create Minimum Sum of Four Digit Number After Splitting Digits
Create Palindrome_Num_Checker.cpp
Update palindrome.cpp
added kadans algorithm and unique element in array code in cpp
greatest element in array
added bfs code
Create NGE.java
Create maximum-product-of-two-elements-in-an-array
…tion added pattern program
Create count-the-number-of-complete-components
Create-take-input-in-string-form-and-convert-to-array-format-for-operation Nikhil-2002#98
…a123-patch-1 Create shortest_path
Created CONTRIBUTING.md for the project
Added Dijkstra's algorithm
Add files and Readme
…ctor Added F1 Race Predictor program for Hacktoberfest 2025
Author
|
Please @Nikhil-2002 label it as "hacktoberfest" and "hacktoberfest-accepted." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We need to calculate how much water can be trapped between bars of different heights after raining.
Approach (Prefix–Suffix / Auxiliary Arrays Method)
The main idea is: For each element, the amount of water that can be trapped above it depends on The maximum height to its left and the maximum height to its right
Water trapped at that position = min(maxLeft, maxRight) - height[i]
So, we first precompute two arrays:
left[i] → highest bar from the start to index i
right[i] → highest bar from the end to index i
Then, for every index i, we find: water[i] = min(left[i], right[i]) - height[i]
Add up all these values to get the total trapped water.