Algorithm to find same element from a point in a random matrix
问题 I'm wondering on how can I do to find, in a random matrix, each same elements from a particular point, and around this point. It's easier to explain in an example : So, in green it is the point that the player chooses. How can I get the position of all these "X" (only lines and columns, not diagonal) ? I thought about an algorithm like Dijkstra or Bellman Ford ? I hope you understand, and sorry for my bad english. Thanks 回答1: Something like depth-first search (DFS) or breadth-first search