SHARE
TWEET

Untitled

a guest Jun 16th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def solution(M, A):
  2.     l = len(A)
  3.     distinct_slice_count = l
  4.    
  5.     # caterpillar method to solve it.
  6.     for p in range(l - 1):
  7.         unique_vals = set([A[p]])
  8.         for q in range(p + 1, l):
  9.             if A[q] in unique_vals:
  10.                 break
  11.             else:
  12.                 unique_vals.add(A[q])
  13.                 distinct_slice_count += 1
  14.    
  15.     return distinct_slice_count
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