We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
O(n^2) time because in the worse case scenario the outer loop will run through the entires string by 1/2 and the while loop will run through all charecters in the string.
O(n) space because the string created will be as long as 's'
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
Here is a O(n^2) time and and O(n) space:
O(n^2) time because in the worse case scenario the outer loop will run through the entires string by 1/2 and the while loop will run through all charecters in the string. O(n) space because the string created will be as long as 's'