# Help with homework :)

Now I have one more homework to do now :). I’m very glad if someone help me

This problem can be discribed:

The number X is called “Father of Y” if we delete some numbers in X, we have Y.

Having two non-negative numbers. Your task is finding the smallest number that can be called as “father” of two given numbers.

Example:

With input:

111999111 999111999

We must output: 111999111999.

More example:

12345 12341 => Output is: 123415.

Limitation:

Let assume you have all characters in two FIFO structres (`q1` and `q2`).

By simple merge I meant something like:

``````res = ""
while ( q1 not empty and q2 not empty ) {
char c1 = q1.top() // get reference on first item
char c2 = q2.top()
if ( c1 == c2 )
res += c1
q1.poll() // remove from structure
q2.poll()
else if ( c1 < c2 )
res += c1
q1.poll()
else
res += c2
q1.poll()
}
add all from q1 to res if not empty // only one can be non-empty
add all from q2 to res if not empty
print res``````

@betlista Can you help me

I wanted to check it first, but I cannot in a job, check yourself if there is also solution - link, but it seems to me, like simple merge problem…

But in that problem, We can only solve subtask 1, is there anyway to solve subtask 2?
note: Le Minh Hoang is a very famous teacher in Vietnam
And in that book I didn’t see any solution @betlista

@betlista If this test : 24 72. your code will output 2472, but the answer is 724.

I thought your question won’t be so easy, but I didn’t see that test case… Hm, is such case I’d try to use largest common subsequence together with this merging (updated) at the end…

Can you describe your idea more clearly?