Блог пользователя nolankeats

Автор nolankeats, история, 2 года назад, По-английски

Yesterday, I came across a question- DZY Loves Chessboard. My first question based on an algorithm. I tried brute force by applying standard 2 loops and all the if else logic, didn't succeed. I then read about dfs and came back to editorial.
I don't think they applied dfs or maybe I didn't understood dfs in first place. But I would really like to learn dfs and solve the related questions. Please provide with some useful links of study material and related questions (with increasing difficulty, if can). As well, if possible point out where I went wrong in my initial logic. Thank you.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

The judge said out of bound on line 40, you have to check for $$$j > 0$$$ before access to $$$arr[i][j-1]$$$

And I don't get the line if(arr[i-1][j] != 'W' && i>=0){, if $$$i = 0$$$ you also get out of bound

Change all these clause to $$$>,$$$ I got WA on test case 2 : link to the submission