Returned "Expected Answer" is wrong, unless I misunderstood the problem statement.


  • 0
    P

    This input:

    [6, 1, 4, 3, 5]
    [3, 8, 4, 2, 2]
    

    Gives correct Expected answer 2

    Now, I assume, that this input should give answer -1:

    [6, 1, 4, 3, 5]
    [3, 8, 4, 3, 2]
    

    however, Expected Answer is 2. Why? If you calculate the total gas amount available - 19 and total gas amount required - 20 one shouldn't be able to complete the circuit regardless of the starting station, right?. Unless I misunderstand the problem statement...

    Additionally, if you change 8 to 9 or 10 in the input array, it still gives expected answer 2. Only if you change 8 to 11 it says -1:

    • #1:

      • Input:
        [6, 1, 4, 3, 5]
        [3, 9, 4, 3, 2]
        
      • Given "Expected Answer" by leetcode:2
      • What is really expected (correct answer):-1
    • #2:

      • Input:
      [6, 1, 4, 3, 5]
      [3, 10, 4, 3, 2]
      
      • Given "Expected Answer" by leetcode: 2
      • What is really expected (correct answer): -1
    • #3:

      • Input:
      [6, 1, 4, 3, 5]
      [3, 11, 4, 3, 2]
      
      • Given "Expected Answer" by leetcode:-1
      • What is really expected (correct answer):-1

    Any thoughts?


Log in to reply
 

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