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.
Well though I have to admit that you're right but in general I love it. Why? It opened my eyes and shaked my mindset. I'd like to say to some degree it was a seminal solution though with some bugs but still worthy.
The worst case is with all
p[i][x]
equal to each other, which gives N^2 (N(N-1)/2 distance calculations). It appears the average complexity is logarithmic though, which is pretty cool!Who can tell me the time complexity of the solution?
Inconceivably!
yes, the tests in this kata are very bad. almost as bad as your ability to read the instructions
I konw why that I'm not thinking about the order of zeros!
the order of your zeros is wrong. for example, if we have the input array [1,2,"0",4,4,0,1,4,"0",2] then the output should be [1,2,4,4,1,4,2,"0",0,"0"]. If the zeros in the back are in any other order, it doesn't work. For example the output [1,2,4,4,1,4,2,0,"0","0"] would be wrong.
Can anyone tell me that eror cause?
log: [ 1, 2, 52, 7, '3', 1, 0, 0, '0', '0' ]
Expected: '[1,2,52,7,"3",1,"0",0,"0",0]', instead got: '[1,2,52,7,"3",1,0,0,"0","0"]'
When I run removeZeros([1,2,52,7,"3",1,"0",0,"0",0]) in my IDE it returns [1,2,52,7,"3",1,"0",0,"0",0].
Where did I go wrong?
I'm sorry. How careless of me.
Wrong solution.How about board with -1 and 10 ? just like this(all 1 is replaced by -1 and all 9 is replaced by 10)
[
[5, 3, 4, 6, 7, 8, 10, -1, 2],
[6, 7, 2, -1, 10, 5, 3, 4, 8],
[-1, 10, 8, 3, 4, 2, 5, 6, 7],
[8, 5, 10, 7, 6, -1, 4, 2, 3],
[4, 2, 6, 8, 5, 3, 7, 10, -1],
[7, -1, 3, 10, 2, 4, 8, 5, 6],
[10, 6, -1, 5, 3, 7, 2, 8, 4],
[2, 8, 7, 4, -1, 10, 6, 3, 5],
[3, 4, 5, 2, 8, 6, -1, 7, 10],
]
Wrong Solution, it can't promise every element in row or column to be diff and locate in [1-9]. Use Set
niubility
Stupid but effective
good job
Loading more items...