@TheLittleNaruto there are few problems I see with it though. First of all, you are taking a new String, then you are using contains on it for every character (if every digit is 9, it'll go up until end), and you are not using the optimised solution, since there is a more optimised solution, which'll work using lesser memory footprint, and will run faster as well.
@BatCat no, I am asking for a solution which runs faster than the current one, and uses lesser memory footprint
@TheLittleNaruto also, lets take it this way. Our string has million digits, and every digit is 9. Now, your solution will parse that string 10 million times.
What if I tell you that we can do it in million times only?
@ShadowWizard lel, we're in hell, @Olivia is pretending to be my manager, and I am just going along, before telling her who I really am, and what spells do I actually hold
@Shadow I noticed you closed this as a duplicate. Now that the parts covered in the target have been removed, could you please reconsider your decision?
(There was a prior minor edit that resulted in a "Leave Closed" review outcome, so the most recent edits won't be reviewed there.)