here is the code.
Problem in my logic
hey @ParthCr7, you are computing overall cost by each possible way and then selecting the minimised answer. But here you have to minimised the cost for each ride.
But the answer should come to be same right?
hey @ParthCr7, no the answer will not be same I have observed it with code. Have to seen the video lecture for this problem made by preteek bhaiya.
In that min and max functions are being used which are not taught to us till now
hey @ParthCr7, there is nothing special in min max function.
- they are present in iostream.h only
- max(a,b) give maximum out of a and b. Similarly min(a,b) give minimum out of a and b.
- they work on two operand only so if you want to find max or min for more than 2 values, you have to modify the code.
example: find max out of a,b,c= max(a , max(b,c)) Similarly for min also
find max out of a,b,c,d= max(max(a,b) , max(c,d)) Similarly for min also
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.