I couldn't understand the question.
For example, the following input will return ArrayIndexOutOfBoundsException, what exactly should the size of nums1 should be?
Can you give some examples what the input look like and the output?
nums1.length() >= m+n, m is the initialized elements in nums1 and n is the initialized elements in nums2. example 1: nums1=[1,2,3,4,5,0,0,0,0,0], m=5 ( zeros are default elements in an array) nums2=[2,3,4,0,0,0,0], n=3 nums1.length() = 10 > 8 (which is m+n) output: [1,2,2,3,3,4,4,5,0,0] example 2: nums1=[1,2,3,4,5,0,0,0,0,0], m=5 nums2=[2,3,4,5,6], n=5 nums1.length() = 10 (which also equals to m+n) output: [1,2,2,3,3,4,4,5,5,6]