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.
You can't really take code out of a function, remove one of the lines, and expected it to still work.
Is this a human? All your kumites are just the default python/javascript tests copied into the code section.
Yup, I tried to prioritize performance and lines of code. But you are right, this solution would not be suitable for work environments.
Yo, this looks clever, but it's very difficult to understand to a third party or yourself at a future date. I'd prioritize readability more.
Third-party-ified
I think the cache is not utilized at all. Noticed when inserting print statement inside return cached value block.
Why did you remove whitespaces?
You don't need a boolean[] as the input. The only concern is the count of urinals.
To ensure that no two persons are standing next to each other, people can simply be placed after leaving one vacant space.
The algorithm you implemented is to ensure that people stand at the farthest distance possible. A simple logic to get to the next to next is enough.
I'm saying the optimality of both the approaches is same. In both the approaches, a simple formula is used to move to the next space.
In any case, if the number of people is greater than ceil (urinalsCount / 2), it will be a cursed situation.
StringBuilder is the easiest way to reverse a string.
It can be done in better time and space complexity than this
refactored tests
Thank you, indeed helpful!
yep you are right, I just added the floor for understanding, didn't mean it to be added in actual code.
is it really important to add floor()? as i is an integer, would it not just run the same amount of loops?
this code doesn't account for primary numbers, can be quickly corrected by checking for ns smaller than 0 and returning false as no negative numbers are prime, a.s - given an integer -n for n as any positive integer -n is always divisible by n which is a divisor other than one and itself
Run the loop only till i < n/2 instead of n (strictly speaking should be only till square root of n but this works too) . That way, in case the number is prime, your loop will only run half as many times (again, this could be improved further by running it floor(sqrt(n)) many times). Just making it more efficient.
Loading more items...