Комментарии:
Thanks for the video
Actually, I did the same idea, but it doesn't pass all test. I am still debugging and have no idea what's going on. When it is obvious NO in the expected it must be YES and vice versa.
But your code is literally the same idea as mine
Hackerrank intentionally makes the problem statement wrong to an easy problem hard.
Ответитьsir, I try it in another test case, this fail, I detect that .sort() didn't change the grid so I have to use grid[i] = sorted(grid[i])
ОтветитьYour example was very helpful; I was beating my head against the wall for hours trying to figure out why my code wasn't working until I realized they described the problem wrong! It's supposed to be n x n grids, but it doesn't actually want that as the answer.
ОтветитьThanks
ОтветитьThe way I solved it doesn't require sorting the characters in every row. I just picked the minimum character of each row and checked if they are in ascending order. That is, I check the minimum of the first row with the next row's minimum character, and keep incrementing rows. I remove the minimum characters if they are less than the minimum of the next row. If not, I return "NO".
ОтветитьVery helpful. Thank you
Ответитьawesome
Ответить