Uber Interview Experience Round 1 – Coding
Summary
I had a coding round interview at Uber where I successfully solved a problem involving reordering elements based on their squares and its follow-up to find the k-th element, demonstrating a two-pointer approach and optimization ideas.
Full Experience
I recently had my first coding round interview at Uber. The interviewer was a Senior SDE. We started with a brief 5-minute introduction.For the main problem, I was asked to reorder elements of a given sorted array based on the sorted order of their squares. I first discussed a brute force approach (square all elements then sort) but didn't code it. Instead, I proposed and successfully implemented a two-pointer / merge-style approach, leveraging the fact that the input array was already sorted.The interviewer then presented a follow-up question: return the k-th element from the square-sorted order obtained from the previous problem. I extended my earlier logic to find the k-th element. Further optimization was requested, for which I proposed a binary search-based idea. Overall, I felt good about my performance in this round.
Interview Questions (2)
Reorder Sorted Array by Sorted Squares
Given a sorted array, reorder the original elements based on the sorted order of their squares. Input: [-3, -2, -1, 0, 1, 2, 3, 4] Output: [0, -1, 1, -2, 2, -3, 3, 4]
Find K-th Element in Square-Sorted Order
Given a sorted array and an integer 'k', return the k-th element from the array reordered based on the sorted order of their squares. Input: [-3, -2, -1, 0, 1, 2, 3, 4], k = 3 Output: 1