I don't know how the case 11, [1,2,3,4,5] , expected answer is 3


  • 9
    I

    For array [1,2,3,4,5], obviously, there is no sub array whose sum equal 11.

    So I think there answer is 0.

    consecutive sub array , right ?


  • 0
    R

    It does not have to be equal, it could be greater too. In this case 3+4+5=12>11.


  • 0
    I

    Thanks for your clarification. I thought it's equal....


  • 1
    D

    @iryan This tripped me too.
    The question has a typo it showed as: "Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ? s."
    For the ? I assumed it was =. Oh well so much time wasted.


  • 0

    @administrators typo in the description, truly wasted my time
    "Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ? s."


  • 0
    A

    Please fix the typo @administrators, so that others may not waste their time like us!


Log in to reply
 

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