Confused about the Run Code Result

  • 1
    def countAndSay(self, n):
        :type n: int
        :rtype: str
        num_dict = dict()
        n_str = str(n)
        output_str = ''
        for i in range(0,len(n_str)):
            if n_str[i] in num_dict:
                num_dict[n_str[i]] += 1
                num_dict[n_str[i]] = 1
        for item in num_dict:
            output_str += (str(num_dict[item]) + item)
        return output_str

    For input 1, my result is "11", which should be correct, while the Run Code expected result is "1". Does Leetcode go wrong?

  • 0

    The judge is correct, "1" is the first sequence.

  • 0

    Have the same confusion.

Log in to reply

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