Last Updated: 27 Nov, 2025

First and Last Character Occurrence

Easy
Asked in company
PayU

Problem statement

You are given a string S and a target character C. Your task is to find the first and last index (0-based) at which the target character C appears in the string S.


There are two possible outcomes:

If the character C is found in the string S, you should report both the index of its first occurrence and the index of its last occurrence.

If the character C is not found in the string S at all, you should indicate this.


Input Format:
The first line contains the string S.

The second line contains a single character C.


Output Format:
Your function should return a string containing the result.


Note:
The search should be case-sensitive. For example, if you are searching for 'a', the character 'A' will not be considered a match.