Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Create Maximum Number

XPChallenge Points: 30
levelLevel: Hard

You are given two digit arrays, nums1 and nums2, representing two separate numerical sequences.
Your task is to form the largest possible sequence of length k, using digits taken from both arrays while preserving the original ordering of digits within each array.

You may choose any number of digits from either array as long as the final sequence length is exactly k and ordering constraints are maintained.

Return the resulting sequence as an array.

Example 1:

Input: nums1 = [5, 1, 9], nums2 = [8, 3, 7], k = 4

Output: [9, 8, 7, 3]

Example 2:

Input: nums1 = [1, 7, 5], nums2 = [6, 2, 8], k = 5

Output: [8, 7, 6, 5, 2]

Example 3:

Input: nums1 = [2, 6, 4], nums2 = [5, 9], k = 3

Output: [9, 6, 4]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result