Largest subarray such that the elements in subarray form a continuous sequence


  • 0
    S
    eg
    without duplicate
    43,7,6,23,8,5, 3,2,4
    
    0/P :5,3,2,4  as it becomes continuous sequence 2,3,4,5
    
    
    eg
    with duplicate
    43,4,3,7,6,23,8,5,5, 3,2,4,5,4
    
    0/P :5, 3,2,4 or  3,2,4,5  as it becomes continuous sequence 2,3,4,5

  • 0
    S

    what i thought of is finding the continuous sequence in 0(N)
    then then finding sub-array by traversing + and - of the starting sequence element

    Is there better solution?


Log in to reply
 

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