Find the two endpoints of the occupied segment on a snowy path by analyzing footprints.
A snowy path contains a sequence of positions. Some positions have footprints, and some do not. The footprints belong to a single person who walked across a continuous segment of the path, leaving footprints on the cells they stepped on.
Your task is to determine the two ends of that occupied segment: the first and last positions that contain footprints. In other words, identify the leftmost and rightmost footprint positions.
This is a straightforward observation and scanning problem: inspect the path, locate the first footprint, then locate the last footprint.
Example 1
Input
8 ..##....
Output
3 4
Explanation
The footprint segment starts at position 3 and ends at position 4.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.