Skip to content

Instantly share code, notes, and snippets.

@virtcoder
Created July 16, 2021 03:43
Show Gist options
  • Save virtcoder/a084df826d1496ef047dab9abff906f0 to your computer and use it in GitHub Desktop.
Save virtcoder/a084df826d1496ef047dab9abff906f0 to your computer and use it in GitHub Desktop.
O: number of steps needed to cut off all the trees in the matrix m x n
I: multidimensional arrays of rows and columns
C: if there are more than one possible paths, need to go to the
next taller tree
E: there is only one tree possible to cut off
steps:
example 1:
as long as the coordinate is within the size of the row and column
1. (0, 0) if it's a tree, if not (0) then find other possible direction
then cut, compare west and south, which on is available and next taller
2. (0, 1) do the same as step 1
3. (0, 2) ----
4. (1, 2) east if not possible, go south
5. (2, 2) east
6. (2, 1) east
7. (2, 0) end of iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment