Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 60 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. def get_len(arr):
  2.     for seq_len in range(len(arr), 0, -1):
  3.         for start in range(len(arr)-seq_len+1):
  4.             stop = start + seq_len
  5.             if sum(arr[start:stop]) == 0:
  6.                 return seq_len, arr[start:stop]
  7.     return 0, []
  8.  
  9. if __name__ == '__main__':
  10.     arr1 = [15, -2, 2, -8, 1, 7, 10, 23]
  11.     arr2 = [1, 2, 3]
  12.     arr3 = [1, 0, 3]
  13.     print(get_len(arr1))
  14.     print(get_len(arr2))
  15.     print(get_len(arr3))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top