how to find a string has duplicate elements or not
Anonymous
Approach taken by Raviteja works optimally in O(n) time, but takes additional O(n) space over this approach which uses bit manipulation. Algorithm used below uses O(n) time and O(1) space. def is_unique_characters(input_string): # Checks corner case if len(input_string)>256: return False val = 0 checker = 0 for ch in input_string: val = ord(ch)-ord('a') # When element repeats if (checker & (1 0: return False checker |= (1<
Check out your Company Bowl for anonymous work chats.