我已经为挑战编写了以下解决方案,但我不确定其时间复杂度:
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)吗?