Computer Science, asked by kollamohanchaitanya, 9 months ago

Given an array of strings arrstr in the format <employee name><employee number>, where employee name contains only alphabets and employee number contains only non-zero
following conditions-
For each string, find the maximum digit in employee number which is less than or equal to the length of the corresponding employee name
• If such a digit is present, concatenate the character present at the position represented by the digit in the employee name to the output
Note: Position starts from one
• If there is no digit which satisfies the above condition, concatenate the character 'X (upper case) to the output
Assumption: There would be minimum two strings in arrstr
Input Format:
Read the collection of comma separated strings arrstr from the standard input stream.
Output Format:
Print the password to the standard output stream
Sample Input
Sample Output
Explanation
Robert:69737,Tina:67281,Jo:38765
tix
Length of 'Robert is
is picked up as the
in Tina's employee
employee number
character of 'Tina
length i.e. 2. So 'X​

Answers

Answered by lokesh6960
0

Answer:

tiX

Explanation:

Length of 'Robert' is 6 and 6 is present in Robert's employ number 69737. 't is picked up as the sixth character of 'Robert Length of 'Tina' is 4 and 4 is not present in Tina's employ number i.e. 67281 so the maximum digit present in Tina's employee number which is less then it's length is 2. Hence 'T' is picked up as the 2nd charater of 'Tina'. For 'Jo' no number is present which is less then or equal to the length Le. 2. So 'X' is added to output. Hence the output is 'tiX'

Similar questions