Suki's Quick Treat Fetch
Suki is a black, curly-coated dog with a grey beard and white paws. She's spotted a delicious pink treat in one corner of a rectangular room, and she wants to reach it as quickly as possible. However, the room contains some furniture and obstacles that block her path. She can only walk through open floor space, moving one cell at a time in any of the four cardinal directions (up, down, left, right).
Given a grid representation of the room, find the shortest distance (minimum number of steps) for Suki to reach the treat from her starting position.
Input
The first line contains two integers R and C (1 ≤ R, C ≤ 100): the dimensions of the room.
The next R lines each contain C characters representing the room:
Smarks Suki's starting position (exactly one).Tmarks the treat's position (exactly one)..marks an open floor cell.#marks an obstacle (wall or furniture).
Output
Print a single integer: the minimum number of steps Suki needs to reach the treat. If the treat is unreachable, print -1.
Notes
Suki can only move through cells marked with . or her starting position S. The treat may be on any cell including T. The shortest path is found using breadth-first search.