SHARE
TWEET

Untitled

a guest Oct 21st, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. str_1 = "leetcode"
  2. str_2 = "loveleetcode"
  3. str_4 = "eeebbbeeem"
  4.  
  5. # get first unique character
  6. table = {}
  7. def unique(s):
  8.   for _, v in enumerate(s):
  9.     if v in table:
  10.       continue
  11.     else:
  12.       table[v] = s.count(v)
  13.     for _, j in enumerate(table):
  14.       if(table[j]) == 1:
  15.         return s.index(j)
  16.         break  
  17.   return -1
  18.  
  19. print(unique(str_1))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top