Find the two endpoints of the occupied segment on a snowy path by analyzing footprints.
Snow 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.
Input Format
- The first line contains an integer — the length of the path.
- The second line contains a string of length consisting of characters representing snowy cells and footprint cells.
Output Format
- Output two integers: the indices of the first and last footprint positions.
- Indices should be reported using the problem's indexing convention.
Constraints
- The string contains at least one footprint cell.
Hints
- A single pass from left to right can find the first footprint.
- A single pass from right to left can find the last footprint.
Input Format
- Read .
- Read a string of length describing the path.
- Footprint cells are the only cells that matter for the answer.
Output Format
- Print the indices of the first and last footprint cells, separated by a space.
Constraints
- The input string has length .
- At least one cell is marked as a footprint.
Example 1
Input
8 ..##....
Output
3 4
Explanation
The footprint segment starts at position 3 and ends at position 4.
Premium problem context
Unlock deeper context for this problem
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.