Algorithm · Google · Medium
You are given a square map with N rows and N columns. Each cell holds one character: S is where the mouse starts, T is where the cheese is, C is where the cat sits, # is water that cannot be crossed, and . is ordinary land. The mouse walks one step at a time to an adjacent cell above, below, left, or right, and may only step onto land cells (the start, the cheese, the cat's cell, and . cells all count as land; # does not). For any route, define its safety value as the…