Number of flag letters


  • 0
    M

    def originalDigits(self, s):
    ans = ""
    count_str = [0]*10
    count_str[0] = s.count("z")
    count_str[2] = s.count("w")
    count_str[4] = s.count("u")
    count_str[6] = s.count("x")
    count_str[8] = s.count("g")
    count_str[1] = s.count("o") - count_str[0] - count_str[2] - count_str[4]
    count_str[3] = s.count("h") - count_str[8]
    count_str[5] = s.count("f") - count_str[4]
    count_str[7] = s.count("v") - count_str[5]
    count_str[9] = s.count("i") - count_str[5] - count_str[6] - count_str[8]
    for i in range(10):
    ans = ans + count_str[i]*str(i)
    return ans


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.