Skip to content

Files

Latest commit

 

History

History

Same characters in two strings - GFG

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Same characters in two strings

Easy

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.


Your Task:  
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