import collections


def longest_substring_deque_rotations(s: str) -> int:
    """
    find the longest substring without repeating characters

    512 ms	14.5 MB
    >>> longest_substring_deque_rotations("abac")
    3
    >>> longest_substring_deque_rotations("abcabcbb")
    3
    >>> longest_substring_deque_rotations("bbbbb")
    1
    >>> longest_substring_deque_rotations("pwwkew")
    3
    """
    words = collections.deque()
    longest = 0
    for char in s:
        for _ in range(len(words)):
            word = words.popleft()
            if char not in word:
                words.append(word + char)
            else:
                longest = max(longest, len(word))
        words.append(char)

    for word in words:
        longest = max(longest, len(word))

    return longest