fork download
  1. class Solution:
  2. def maxDifference(self, s: str) -> int:
  3. mx_odd = 0
  4. mn_even = 10000
  5. dic = {}
  6. for char in s:
  7. if char not in dic:
  8. dic[char] = 1
  9. else :
  10. dic[char] += 1
  11.  
  12.  
  13. for val in dic.values():
  14. if (val % 2 == 0):
  15. mn_even = min(mn_even,val)
  16. else:
  17. mx_odd = max(mx_odd,val)
  18.  
  19. return (mx_odd - mn_even)
Success #stdin #stdout 0.1s 14096KB
stdin
Standard input is empty
stdout
Standard output is empty