
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.
The first line contains the string S.
The second line contains a single character C.
Your function should return a string containing the result.
The search should be case-sensitive. For example, if you are searching for 'a', the character 'A' will not be considered a match.
hello world
l
2 9
The character 'l' first appears at index 2 and last appears at index 9 in the string "hello world".
programming
z
Character not found
The character 'z' does not exist in the string "programming".
The expected time complexity is O(N).
1 <= length of S <= 10^5
The character C will be a single ASCII character.
Time limit: 1 sec