Find Character

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Authors:
Problem type
Allowed languages
Python

Problem Statement

Given a string S and a target character t, return the first occurence(0-index) of t in S. If t is not in S then return -1.

Input Specification

The first line of the input gives the number of test cases, T, T test cases follow. Each test case consists of a line. The line contains a string S and a target character t seperated by a space. The string S will contain only uppercase and lowercase English letters.

Limits

Memory limits: 32MB.

Time limits: 1 second.

1 \leq T \leq 100

1 \leq \text{length of S} \leq 10000

Test Set 1

Sample Case.

Test Set 2

1 \leq \text{length of S} \leq 100

Test Set 3

1 \leq \text{length of S} \leq 1000

Test Set 4

1 \leq \text{length of S} \leq 10000

Output Specification

For each test case, output one line containing Case #x: y, where x is the case number(starting from 1) and y is the position of character t in S.

Sample Input

2
ABC C
HelloWorld A

Sample Output

Case #1: 2
Case #2: -1

Hint

`find()` `linear search`

Comments

There are no comments at the moment.