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 could use the
.scan()
over iter to hold the stateAlmost did the same thing...but I changed the trait bounds on
array_diff
to also require thatT
implement theCopy
trait.Then I used
iter
andcopied
instead of just usinginto_iter
like I should have...because I initially misspelledinto_iter
while trying this exact thing :PYes, but array sizes are quite small in test cases, so creating additional structures can be less productive in this specific case.
This code has O(n*m) runtime as for each element we have to re-scan in b from scratch.
I never knew there was a min function on iter, so short and clever
This comment is hidden because it contains spoiler information about the solution
I forgot about iterators on the array. I need to stop thinking of Rust arrays as C style arrays. I converted my array to a vec first but essentially my solution was the same.
nvm it was just a typo.
This compiles and runs perfectly. Could you copy your code here?
i tried this and kept getting an error when
a[]
was emptyI like this solution alot, I thought some thing like this was possible, but my Rust-foo is not strong enough and I have a hard time navigating the documentation to dig up the idiomatic Rust examples
.
Use integers as soon as possible -> no rounding needed... Cheers.
PS: note that more than 10000 guys passed the kata.
This comment is hidden because it contains spoiler information about the solution