Advertisement
Korotkodul

B

Sep 6th, 2024 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. #букв английского алфавита, десятичных цифр и пробелов
  2. alph = 'abcdefghijklmnopqrstuvwxyz' + ' ' + '0123456789'
  3. met = {}
  4. for l in alph:
  5.     met[l] = -1
  6.  
  7. s = input()
  8. n = len(s)
  9. l = 0
  10. r = 0
  11. met[s[0]] = 0
  12. maxl = 1
  13. r += 1
  14. while r < n:
  15.     while met[s[r]] >= l and l + 1 < n:
  16.         l += 1
  17.         met[s[l]] = l
  18.     cur = r - l + 1
  19.     maxl = max(maxl, cur)
  20.     met[s[r]] = r
  21.     r += 1
  22. print(maxl)
  23. #pwwkEw
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement