This question evaluates array-manipulation and in-place algorithm skills, including understanding of sorted-data merging, index/pointer management, and analysis of time and space complexity within the Coding & Algorithms domain.
Given two arrays arr1 and arr2, both sorted in ascending order.
arr1
in-place
to contain all elements from
arr1
and
arr2
in
ascending
order.
Assumptions/clarifications you may use:
arr1
has enough extra capacity at the end to hold all elements of
arr2
(e.g.,
arr1
length is
m + n
, where the first
m
entries are valid and the last
n
are empty slots), and
arr2
has length
n
.
m
and
n
.
Follow-ups:
Define the time and space complexity of your approach.