Instacart·Machine Learning Engineer·Technical Phone Screen
- Given a sorted array of integers (possibly with negatives), return a new array of the squared values in non-decreasing order. Can you do it in O(n) time?
“I knew the naive version immediately, square everything and sort, but they wanted O(n) and I fumbled around for a bit before landing on the two-pointer idea.”