![]() |
VOOZH | about |
Given two numbers N and M, the task is to find the count of digits in N and M that are the same but present on different indices.
Examples:
Input: N = 123, M = 321
Output: 2
Explanation: Digit 1 and 3 satisfies the conditionInput: N = 123, M = 111
Output: 0
Approach: The problem can be solved using hashing and two-pointer approach.
Below is the implementation of the above approach:
2
Time Complexity: O(D), where D is the max count of digits in N or M
Auxiliary Space: O(D), where D is the max count of digits in N or M