+ 1

Can this be considered O(n)?

Sorry for the mess! https://code.sololearn.com/cUl7x6aVpMpa/?ref=app

6th Jun 2018, 8:22 AM
Zuke
Zuke - avatar
1 Réponse
+ 1
Yup. string.lower() is O(n), so is line 4, and line 5. string.replace() runs at most once so that adds another O(n). So we are in the ballpark of 4*n operations, which is O(n) :)
6th Jun 2018, 9:25 AM
Schindlabua
Schindlabua - avatar