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.
- Separate the Numbers
- Discussions
Separate the Numbers
Separate the Numbers
Sort by
recency
|
101 Discussions
|
Please Login in order to post a comment
I spent like 10 hours trying to do this the hard way. When I figured out the easy way I did it in 5 minutes during a business meeting. Do yourself a favor:
For input "99100", grab the first digit 9 and build beautiful string 91011, and check whether it's identical to 99100, It's not. So grab the first 2 digits 99 and build beautiful string 99100. It's identical, so "YES 99".
Don't try to stairstep a left index and a right index or dynamically keep track of curernt index length or anything. Save it for the harder questions lmao.
I have no clue in whos vocab is this a Basic - Easy questions. This is more like a medium question and I would say a harder one of that.
I have used a backtracking kind approach. Try diff length numbers to begin the recursive calls, then check if the next number we can come up with is +1 of previous. If we find a number like that we have another recursive call.| If the number is too big we can stop and return false. If the starting number size is already more than half the digits count we can also stop.
Let's talk about constraints...
The constraints listed on this problem are EXTREMELY MISLEADING! There was a crazy amount of guessing on this problem to figure out which constraints the hackerrank brain was assuming since the ones written did not work.
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions