Ad
  • Custom User Avatar

    Questions asks not to modify input array for some reason

  • Custom User Avatar

    Incorrect solution for problem - must modify input matrix.

  • Custom User Avatar

    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!

  • Custom User Avatar

    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?

  • Custom User Avatar

    Dont change s (the input list)

  • Custom User Avatar

    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.

  • Custom User Avatar
  • Custom User Avatar

    Also totally agree, feels more like a 7 Kyu

  • Default User Avatar

    Yeah ok makes sense, thanks

  • Custom User Avatar

    Please read the description of this kata carefully - the tests are correct!!

    Much easier to solve this iteratively than recursively.
    I personally had some testing issues when trying to import my recursive function (including a global count variable) into CW. I passed the 4 basic tests in my IDE, however when that same code inputted into CW the some of those basic tests failed. Maybe CW didn't like that I had declared a global variable within a function? Can anyone shine some light on this - Thanks

  • Default User Avatar

    I have a similar issue, with a similar style question. I think he means that when he is running the same tests in his IDE, it returns the correct results. But when the same code is inputted into CW, some tests fail.
    Not sure if this is because your IDE is python 3.8 and CW is running the question in 3.6?