Champagne Tower


  • 0

    Click here to see the full article post


  • 0

    why bother double[][] A = new double[102][102];?
    double[][] A = new double[101][101]; is also ACed since the given contraint: query_glass and query_row will be in the range of [0, 99].


  • 0
    T

    why we need to take min (return Math.min(1, A[query_row][query_glass]);) ?


  • 0
    J

    @terminator123456 we take the min because if it's over 1 it would inevitably overflow to the glasses below, but no reason to calculate that as we already found out that the glass we are querying is already going to be full.


  • 0
    A

    @terminator123456 Because this algorithms consider the flow through each glasses, so to some glasses, the flow would be over 1. But the answer to the question is full = 1, so the answer is selected between the min value of 1 and flow q


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.