Utkarsh and Placement tests Codechef solution in Java, C++ || UTKPLC || December long challenge 2021
Utkarsh and Placement tests Codechef solution in Java, C++
Note: Hope it helps you! Please note that all the intentions are to clear the doubt of how to solve it in java. So, please try to give it a chance at least before using this. If you face any discrepancy please contact us. Thank you!
Utkarsh is currently sitting for placements. He has applied to three companies named and
You know Utkarsh's order of preference among these companies, given to you as characters first
, second
, and third
respectively (where first
is the company he prefers most).
You also know that Utkarsh has received offers from exactly two of these three companies, given you as characters and .
Utkarsh will always accept the offer from whichever company is highest on his preference list. Which company will he join?
Input Format
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains three different space-separated characters:
first
,second
, andthird
, denoting Utkarsh's order of preference among the three companies. - The second line of each test case contains two space-separated characters and , the companies from which Utkarsh has received offers.
Output Format
For each test case, print one line containing a single character, the company whose offer Utkarsh will accept.
The output is not case sensitive, so if the answer is , both and will be accepted.
Constraints
first
,second
andthird
are three different characters among .- and are two different characters among .
Subtasks
Subtask #1 (100 points): Original constraints
Sample Input 1
2
A B C
A B
B C A
A C
Sample Output 1
A
C
Explanation
Test Case 1. Utkarsh has received offers from and . Of these two, he prefers company (first preference) over (second preference). Therefore Utkarsh will accept the offer of company .
Test Case 2. Utkarsh has received offers from and , where company is his second preference and company is his third preference. Utkarsh will accept the offer of company .
helped me a lot
ReplyDeleteThank you so much