You are given two strings A and B. Your task is to find and return a string representing…
- User
You are given two strings A and B. Your task is to find and return a string representing the leftover string in A after removing all the letters that exist in string B. Return "Empty" if the output does not contain any value.
Note:
Strings A and B contain English alphabets in upper case only. A single alphabet in B can replace all the occurrences of that alphabet in A. Input Specification:
input1: A string A input2: A string B Output Specification:
Return a string representing the leftover string in A after removing all the letters that exist in string B.
Example 1
input1: AABBC input2: AB Output:
CC
Explanation:Here, the given string A is "AABBC" and B is "AB". We need to remove all the occurrences of characters 'A' and 'B' from string A. After removing them, we will be left with only 'CC'. Therefore, CC is returned as the output. Example 2:
input1 : AABBC input2 : ABCDDSD
Output: Empty
Explanation:
Here, the given string A is "AABBC" and B is "ABCDDSD". We need to remove all the occurrences of characters 'A', 'B', 'C', 'D' and 'S' from string A. After removing them, we will be left with an empty string, so Empty is returned as the output. give c++ optimised code in two functions
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.