Definition of "Subarray"?

  • 3

    The questions states(on June/17):

    Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.

    Beware of the definition of "subarray", subarray don't have to be continuous.What is difference between subarray and contiguous subarray?

    I tried test case: [1,-2,3], 4.

    The top-voted solution and the OJ both return 0, rather than 2 ({1,3}).

    Let's assume the question take non-continuous subarray into account, any idea on solving the non-continuous subarray case? It seems that O(N) time is hard.

    Thanks in advance.

Log in to reply

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