3 ms·The substring implementation is O(n), it's the loop popping off a letter at a time that ends up O(n^2).by magicalist 10y agoThe substring implementation is O(n), it's the loop popping off a letter at a time that ends up O(n^2).