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.
This comment is hidden because it contains spoiler information about the solution
I think there's a problem with random tests. Some of them have wrong output.
For example this one:
A test says that we cannot catch mouse within 9 moves. But it's not true. If we move horizontally we are able to catch mouse in 5 moves.
Here's how to do that:
For each move we take 9 steps and have to make 5 moves in total to reach the mouse.
.repeat
also depends onn
so time complexity is O(nlogn)I wouldn't recommend using bitwise operators in production code they are really hard to understand and debug. I had hard time debugging production code that utilized bitwise operators.
There's a way to make it one line tho :)
One line solutions are usually not the best ones (in terms of performance and readability) but people still upvote them because they look cool
This comment is hidden because it contains spoiler information about the solution
Finally a O(n) solution!
Isn't it the whole point of these coding tasks — to find a performant solution (in terms of big O)?
This comment is hidden because it contains spoiler information about the solution
/
This comment is hidden because it contains spoiler information about the solution
No, you are wrong here. The description says:
Your task is to remove everything inside the parentheses as well as the parentheses themselves.
. So we remove any parentheses even the ones that have no opening/closing one.Actually yours and his solutions are O(n^2) so you can't say his solution is a much slower one.
But I like the way you search for palindromes in your solution tho!
Wow! Thanks! Didn't understand how to approach this one so solved the one you recommended first and now the solution for this one is clear to me :)
Yes, there's a difference. Your solution in fact more performant than the OP's solution. His solution has O(n^2) time complexity and yours is O(n) meaning it's much faster.
Loading more items...