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.
Questions asks not to modify input array for some reason
Incorrect solution for problem - must modify input matrix.
Hey there, I just completed this one on Leetcode and thought I would grab some codewars points for it as well if it was on here.
I was wondering if someone could shed some light on my solution for me - while it does pass all the tests, am I not technically going against the rules of the problem by making another 2d-array?
I know I got around it by doing "matrix[:] = res", but doesn't that kinda beat the point of the problem? All my test cases were accepted on both Leetcode and here, but I wanted some clarification on whether this type of thing was allowed for questions that state "Do not return anything, modify matrix in-place instead."
Cheers!
So you are doing s = ...
The idea is that you dont mutate the input, which will be one of the errors you will get with this while code testing. I think you would likely also timeout with the [::-1] reverse method?
This comment is hidden because it contains spoiler information about the solution
I agree with the comment about the instructions being unclear but will accept the challenge to not use pop - as that was part of my solution. Thanks for feedback everyone.
.... but the instructions tell us to remove them : "Remove the first and last element from the list S" so in my opinion the instructions are not clear
Dont change s (the input list)
well, that means you're currently "mutating the input" while you shouldn't... ;)
=> don't use pop/insert/append, or stuff like that. A bit of googling might help too.
I'm getting the 'don't mutate the input' error for pretty much all the tests. I don't understand what that is testing for. Can you explain that please?
Nice kata - thanks for this. A good emphasis on time complexity for this one. My first solution was really simple but obviously no good for very large lists.
My second one was faster, but only just scraped it with like 10000 ms haha, nice to see the other solutions though.
Nice solution!
Also totally agree, feels more like a 7 Kyu
What I did is I created a new function and pass on a local variable inside the persistence method. For some reasons, the code doesn't wanna exit as soon as it reaches a return line. wth.
Yeah ok makes sense, thanks
Loading more items...