Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve():
- a = list(map(int, input()))
- left = 0
- count = [0] * 3
- count[a[0]-1] = 1
- min_len = 2 * 10**5 + 1
- for right in range(1, len(a)):
- count[a[right]-1] += 1
- while left <= right and count[a[left]-1] >= 2:
- count[a[left]-1] -= 1
- left += 1
- if count[0] > 0 and count[1] > 0 and count[2] > 0 and right - left + 1 < min_len:
- min_len = right - left + 1
- if min_len < 2 * 10**5 + 1:
- return min_len
- else:
- return 0
- for _ in range(int(input())):
- print(solve())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement