#C14894. Multi-Function Utility
Multi-Function Utility
Multi-Function Utility
This problem requires you to implement a multi-function utility program that supports four operations:
- Operation 1: Find the first non-repeating character in a string. If none exists, output
None
. - Operation 2: Given a sequence of integers from 1 to n with one missing number, find and output the missing number.
- Operation 3: Reverse the order of words in a given sentence.
- Operation 4: Merge two sorted arrays into one sorted array and output the merged array (space‐separated). If the merged array is empty, output an empty line.
The input will consist of multiple queries. For each query, you will read the operation type and the corresponding data, and output the result on a separate line.
inputFormat
The first line contains an integer T, representing the number of queries. Each query is formatted as follows:
- The first line of each query contains an integer op (1 ≤ op ≤ 4) indicating the operation type.
- If op = 1: The next line contains a string. You must output its first non-repeating character (or
None
if there is none). - If op = 2: The next line contains an integer n (the full range is 1 to n), and then a line with n-1 space-separated integers representing the sequence missing one number. Output the missing number.
- If op = 3: The next line contains a sentence. Output the sentence with the order of words reversed.
- If op = 4: The next line contains two integers n and m (sizes of two arrays), followed by a line with n space-separated sorted integers, and then a line with m space-separated sorted integers. Output the merged sorted array as space-separated integers.
outputFormat
For each query, output the corresponding result on a separate line. For operation 4, if the merged array is empty, output an empty line.
## sample4
1
aabcc
2
5
1 2 3 5
3
Hello World
4
3 3
1 3 5
2 4 6
b
4
World Hello
1 2 3 4 5 6
</p>