Daily Quiz-2 - Accenture Pattern
Daily Quiz-2 - Accenture Pattern
Repeating Digit:
Implement the following function:
def CommonDigits(a,b,c):
The function accepts three positive integers a,b,c as its argument. Implement the function to
find and return the common digit in all three numbers if the no common digit then return 1.
Assumption:
All 3 numbers are three digit numbers
ABC numbers can have at most 1 digit common
Example:
Input:
a:426
b:486
c:652
output:
6
Explanation:
6 is common digit in all the three numbers, thus,6 is the output
The common input format for the above case:
426
486
652
(the first line represents a, the second line represents b,the third line represents c)
Question-2
Problem Description :
The Binary number system only uses two digits, 0 and 1 and number system can be called
binary string. You are required to implement the following function:
int OperationsBinaryString(char* str);
The function accepts a string str as its argument. The string str consists of binary digits
separated with an alphabet as follows:
– A denotes AND operation
– B denotes OR operation
– C denotes XOR Operation
You are required to calculate the result of the string str, scanning the string to right taking
one operation at a time, and return the same.
Note:
No order of priorities of operations is required
Length of str is odd
If str is NULL or None (in case of Python), return -1
Input:
str: 1C0C1C1A0B1
Output:
1
Explanation:
The alphabets in str when expanded becomes “1 XOR 0 XOR 1 XOR 1 AND 0 OR 1”, result
of the expression becomes 1, hence 1 is returned.
Sample Input:
0C1A1B1C1C1B0A0
Output:
0