Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
For me , this is not best practise , because you will calculate the min and max while the input array is already sorted , view my solution.
Better case is:
$this->assertSame(9199999999999999999, nextBigger(1999999999999999999));
This seems quciker then what i wrote lol
Be very carefull with eval. Basically you should not do it. And if you do - sanitize input.
i agree it will re execute the count in each iteration, but maybe he leave it like that to save 1 line of code at the cost of little eficiency.
A pleasure sir, it's always worth trying to formulate any constraints until you find a set that can be resolved.
Thank you for the comments on your solution
It's a shame that I didn't think of this solution myself.
Although initially I wrote down these dependencies in the form of a system of equations. But I did not guess to express the time of the walk through the time by taxi.
Thank you very much.
Fixed tests. And now your solution doesn't work. I'm sorry. :)
Thanks. I will add a test
This comment is hidden because it contains spoiler information about the solution
Your testcase is wrong. The next bigger value of 1111111111111111119 is 1111111111111111191.
But your assumption is right: Searching for the solution iteratively is wasting lots of CPU, so this isn't qualifying as "clever" in the sense of "using an approach that is not brute-forcing it, but identifying the problem as what it truly is, and applying a very good solution to it".
But it might qualify for "clever" as in "applying a solution that isn't obvious".
I know about this. it is a very hard problem. Only one small assert and 6 months. :)
This comment is hidden because it contains spoiler information about the solution
Guys, is this the best solution or clever?
Here's a simple additional test for you.
$this->assertSame(1911111111111111111, nextBigger(1111111111111111119));
And then enjoy how your solution will work.
This comment is hidden because it contains spoiler information about the solution
Loading more items...