Panda Guru LogoPanda
Guru

Paypal SDE Interview

Round 1

Questions: Given an integer array, nums, sorted in non-decreasing order, return an array of squares of each number sorted in non-decreasing order. Example:

nums = {-4, -1, 0, 3, 10} result = {0, 1, 9, 16, 100}
Candidate's Approach
  • The candidate used two pointers, one starting from the beginning (left) and the other from the end (right) of the array.
  • They computed the squares of the values at both pointers and compared them.
  • The larger square was appended to the result array, and the corresponding pointer was moved inward.
  • This approach ensures that the result array is filled in reverse order, which is then returned.
Interviewer's Feedback

No feedback provided.