Question: in c++ Write a function int howmuchwater(unsigned int a[], int n) where a[] is a 1D array where a[i] reports the number of blocks stacked
in c++
Write a function int howmuchwater(unsigned int a[], int n)
where a[] is a 1D array where a[i] reports the number of blocks stacked atop square i n is the number of elements in a[] and returns the cubic feet of trapped water from blocks described in a[] if n>0 and a[] is non-null, otherwise returns -1.
Examples:
a)
b b b b b b b b b ++++++++++ 7
b)
b b bb b b bb bbbbbbb +++++++++++++ 6
c)
+++ 0
d)
b +++ 0
e) -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
