daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. q = list(map(int,input().split()))
  3. i = 0
  4. a = -1
  5. b = 0
  6. w = []
  7. for i in range(0,n):
  8.     if (a==q[i]):
  9.         b += 1
  10.     else:
  11.         w.append(b)
  12.         w.append(a)
  13.         a = q[i]
  14.         b = 1
  15. w.append(b)
  16. w.append(a)
  17. print(*w[2:])
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