0% found this document useful (0 votes)
6 views2 pages

Coding Question 4

The document describes a problem where the number of common characters between two strings needs to be calculated for multiple test cases. It specifies the input format, including the number of test cases and the strings, as well as the output format, which is the count of common characters for each test case. Constraints are provided to define the limits on the number of test cases and the length of the strings.

Uploaded by

John Philip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Coding Question 4

The document describes a problem where the number of common characters between two strings needs to be calculated for multiple test cases. It specifies the input format, including the number of test cases and the strings, as well as the output format, which is the count of common characters for each test case. Constraints are provided to define the limits on the number of test cases and the length of the strings.

Uploaded by

John Philip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Find the number of commom characters in two strings

Input
The first line of the input contains an integer T, denoting the number of test
cases. Then the description of T test cases follows.

The first line of each test case contains a string A. The next line contains
another character string B.

Output
For each test case, output a single line containing a single integer, the common
characters in A and B.

Constraints
1 ≤ T ≤ 100
1 ≤ |A|, |B| ≤ 10000

ST:
4
abcd
xyz
abcd
bcda
apbc
akbc
moedhecf
elfedcc

SO:
0
4
3
5

Exp:
Example case 1. There is no common character.

Example case 2. All the characters are same.

Example case 3. Three characters (a, b and c) are same.

TC1:
2
abcdefrstuvwxyz
abghijklmnrstuv
qwerty
uiopwefghj

OP1:
7
2

TC2:
2
aaaa
bbbb
aaaa
aaaa

OP2:
0
4

TC3:
2
abcdefghijklmn
owierpoiweopij
xcbzlkjxbclkjb
posidhfoisdfhh

OP3:
3
0

TC4:
2
aabbccddeeeeeffffffggggg
aabbccddeeffffffgggghhhh
abcdefgghhiijjkkllmmmm
abcdmmmhijk

OP4:
20
11

You might also like