小编cpi*_*pit的帖子

这个解决方案的时间复杂度是O(logn)吗?

我已经为挑战编写了以下解决方案,但我不确定其时间复杂度:

def ASCIIConversion(string): 
    newStr = ''

    for chr in string:
        if chr.isspace(): 
            newStr = newStr + ' '
        else:
            newStr += str(ord(chr))

    return newStr
Run Code Online (Sandbox Code Playgroud)

由于else语句,程序的复杂性是O(logn)吗?

python big-o time-complexity

1
推荐指数
2
解决办法
60
查看次数

标签 统计

big-o ×1

python ×1

time-complexity ×1