check if all characters in the string is unique or not iscontainsuniquecharsilove py true iscontainsuniquecharsi don t love python false time complexity on space complexity o1 19320 bytes as we are having 144697 characters in unicode each bit will represent each unicode character for example 65th bit representing a https stackoverflow coma12811293 if we already turned on bit for current character s unicode check if all characters in the string is unique or not is_contains_unique_chars i_love py true is_contains_unique_chars i don t love python false time complexity o n space complexity o 1 19320 bytes as we are having 144697 characters in unicode each bit will represent each unicode character for example 65th bit representing a https stackoverflow com a 12811293 if we already turned on bit for current character s unicode
def is_contains_unique_chars(input_str: str) -> bool:
    

    
    
    
    bitmap = 0
    for ch in input_str:
        ch_unicode = ord(ch)
        ch_bit_index_on = pow(2, ch_unicode)

        
        if bitmap >> ch_unicode & 1 == 1:
            return False
        bitmap |= ch_bit_index_on
    return True


if __name__ == "__main__":
    import doctest

    doctest.testmod()