Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question The current selected programming language is C + + 1 4 . We emphasize the submission of a fully working code over partially correct

Question
The current selected programming language is C++14. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use cout to debug your code. The cout may not work in case of syntax/runtime error. The version of GCC being used is 5.5.0.
In a university every student is given a student ID and university enrolment number. These both contain digits (0-9). The student ID contains M digits, and the university enrolment number contains N digits. Every subject is given a unique subject code. While developing a student examination hall entrance system, the system must take the student ID, the university enrolment number, and the subject code P for which the student is taking an examination. The system must generate the entrance code for the student from the digits of the student ID and the university enrolment number. The generated entrance code must be the largest number of length P made up of digits from the student ID and the university enrolment number. The relative order of the digits from the student ID and the university enrolment number must be preserved.
Write an algorithm to find the largest number of length P made up of digits from the student ID and the university enrolment number.
Input
The first line of the input consists of an integer - idDigitList_size, representing the number of digits in the student ID (M).
The next line consists of M space-separated integers -idDigitList[0], idDigitList [1],....., idDigitList[M-1], representing the digits in the order in which they are present in the student ID.
The next line consists of an integer - enRollDigitList_size, representing the number of digits in the university enrolment number (N).
The next line consists of N space-separated integers - enRollDigitList[0], enRolIDigitList [1],....., enRollDigitList[N-1, representing the digits in the order in which they are present in theuniversity enrolment number
The next line consists of an integer - subCode, representing the subject code P for which the student is taking an examination (P).
Input
The first line of the input consists of an integer - idDigitList_size, representing the number of digits in the student ID (M).
The next line consists of M space-separated integers -idDigitList[O], idDigitList [1],...., idDigitList[M-1], representing the digits in the order in which they are present in the student ID.
The next line consists of an integer - enRollDigitList_size, representing the number of digits in the university enrolment number (N).
The next line consists of N space-separated integers - enRollDigitList[[0], enRol/DigitList [1],....., enRollDigitList[N-1, representing the digits in the order in which they are present in theuniversity enrolment number
The next line consists of an integer - subCode, representing the subject code P for which the student is taking an examination (P).
Output
Print P space-separated integers representing the digits of the largest number forme from the student ID and the university enrolment number in the order present.
Constraints
100090N-100DigitListsize, enRollDigitListsize 100
0 idDigitList[0], idDigitLlist[1],......, idDigitList[M-1]9
0 enRollDigitList[0], enRollDigitList [1],...., enRollDigitList[N-1]9
0 subCode rollDigitListsize +enRollDigitListsize
Example
Input:
3
265
4
1582
4
Output:
8652
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

b. What is the persons job title?

Answered: 1 week ago