X DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Same characters in two strings
Easy Accuracy: 73.14% Submissions: 398 Points: 2

Given two strings A and B of equal length, find how many times the corresponding position in the two strings hold exactly the same character. The comparison should not be case sensitive.

Example 1:

Input:
A = choice
B = chancE
Output: 4
Explanation: characters at position 0, 1, 4 and 5
are same in the two strings A and B.

Example 2:

Input:
A = Geek
B = gang
Output: 1
Explanation: charactera at position 0 is the
same in the two strings A and B.

You dont need to read input or print anything. Complete the function sameChar() which takes the two strings A and B as input parameters and returns the count of the characters that are same in A and B.

Expected Time Complexity: O(N) where N is the length of strings A and B.
Expected Auxiliary Space: O(1)

Constraints:
1<= A.length(), B.length() <= 104

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  