Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits.
Note: You should try to optimize your time and space complexity.
321. Create Maximum Number
Difficulty: Hard
Given two arrays of length
m
andn
with digits0-9
representing two numbers. Create the maximum number of lengthk <= m + n
from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of thek
digits.Note: You should try to optimize your time and space complexity.
Example 1:
Example 2:
Example 3: