整数中1出现的次数(从1到n整数中1出现的次数)

2014-10-22 0 802
整数中1出现的次数(从1到n整数中1出现的次数)
# -*- coding:utf-8 -*-
class Solution:
    def NumberOf1Between1AndN_Solution(self, n):
        count = 0
        for item in range(1,n+1):
            pstr = str(item)
            count += pstr.count('1')
        return count

遇见资源网 python 整数中1出现的次数(从1到n整数中1出现的次数) http://www.ox520.com/14862.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务