Confused by the test case [-2, 3 -4]


  • 1
    S

    Hi there leetcoders,

    I can't digest why the expected output of the testcase [-2, 3 -4] is 24? The numbers aren't contiguous!!

    And how do you obtain 24? |-2| * |3| * |-4| ???? Weird! Haaallppp!!!


  • 0
    C

    I don't understand your question. -2 * 3 * -4 is indeed equal to 24. And it is a contiguous subarray (which happens to be the array itself).


  • 1
    M

    Hmm, actually I had the same understanding with you. I thought that a continuous subarray should be like [2,3,4] or [4,3,2], or [-2,-3,-4], and like that.

    But a continuous subarray means that the indice are continuous not the actually numbers. So, [-2,3,-4] is actually a continuous subarray which has the maximum product of 24.


  • 2
    F

    Sub array contiguous, not meaning that the numbers are contiguous.
    That means, for example you have Array called a, contiguous sub array means that : a[0],a[1],a[2] or a[2],a[3],a[4] or a[4],a[5],a[6]


  • 0
    S

    ooh.ok! Thanks for the help guys! So contiguous is all about the array indices! That was helpful :)


  • 0
    C

    wow, this is a word trick...


Log in to reply
 

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