Create Maximum Number
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given two arrays nums1 and nums2 of single digits and an integer k. Build a number with exactly k digits by choosing digits from both arrays. The digits you take from one array must keep their original relative order, but you can interleave the two arrays however you like.
Return the largest possible number as an array of its k digits. Numbers of equal length are compared digit by digit from the left.
k is at most nums1.length + nums2.length.
Examples
Constraints
- 1 <= nums1.length, nums2.length <= 500
- 0 <= nums1[i], nums2[i] <= 9
- 1 <= k <= nums1.length + nums2.length
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.