Have an array we have to find longest subarray with consecutive numbers

Have an array we have to find longest subarray with consecutive numbers

ex [4,5,34,33,32,11,10,31]

answer is [31,32,33,34]

 

[92 26 30 28 27]
answer is [27, 28]
NOT [26, 27, 28]
because 26, 27, and 28 are not in a contiguous subarray
posted @ 2013-01-25 16:37  百分百好牛  阅读(123)  评论(0编辑  收藏  举报