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.
- Prepare
- Algorithms
- Strings
- Separate the Numbers
- Discussions
Separate the Numbers
Separate the Numbers
Sort by
recency
|
681 Discussions
|
Please Login in order to post a comment
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'
Here is problem solution in python, java c++ c and javascript- https://programmingoneonone.com/hackerrank-separate-the-numbers-solution.html
thanks
Here is my easy C++ solution, explanation here : https://youtu.be/e32U19k1X6A