[Python] [Algorithm] 가장 많이 등장하는 알파벳 갯수 세기

2021. 6. 24. 13:43🧑🏻‍💻/Python

word = "chanhhh"

def highFrequencyLetterCount(word):

  map = {}
  for alphabet in word:
    print("map :",map)
    if map.get(alphabet) == None:
      map[alphabet] = 1      
    else:
      map[alphabet] += 1
    
    print(map)

  max = -1
  for key in map:
    print("key :", key, "value :", map[key],
          "max :", max)
    if map[key] > max:
      max = map[key]
  print(max)

  return max

highFrequencyLetterCount(word)