Statement You are given two numbers x and y represented as strings. y is generated by random shuffling x and then adding 0 to n more digits at any random positions. Create a function that takes in these two numbers (x and y) as string inputs and returns the newly inserted digit(s) that was/were added to y in the form of a concatenated string of all the newly added digit(s) in an ascending order. ou must use a set or map data structure from STL to solve the problem. Note: A single digit can be added more than once in the new number. Constraints • x and y > 0 • 0 < x.length, y.length <= 10^8 y.length >= = x.length Example 1 Input: 8 56981234 Output: 1234569 Example 2 Input: 1234 12345 Output: 5 Explanation The sample input consists of two strings separated by a space and the sample output consists of the newly inserted digit(s) that was/were added to the shuffled first string in an ascending order.
Solution 1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 5 std::string findTheDigits (std::string x, std::string y) { // Write your code here return ""; 678 } Stdin Compiler Output Submission 1234 12345 I 0+ 0 Run Code Submit
Find the Digits Problem Find the Digits Problem Statement You are given two numbers x and y represented as strings. y is generated by random shu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am