fork download
  1. # your code goes here
  2. class Solution(object):
  3. def maxDifference(self, s):
  4. """
  5. :type s: str
  6. :rtype: int
  7. """
  8. even_count = []
  9. odd_count = []
  10.  
  11. for char in set(list(s)):
  12. count = s.count(char)
  13. if count % 2 == 0:
  14. even_count.append(count)
  15. else:
  16. odd_count.append(count)
  17.  
  18. return max(odd_count) - min(even_count)
  19.  
  20.  
Success #stdin #stdout 0.09s 14072KB
stdin
Standard input is empty
stdout
Standard output is empty