Paypal SDE Interview experience

Background- 3+ YoE

Round 1: Technical Interview (Golang)-

Resume based questions were asked, based on the tech stack I had used and explanation of the tech stack I use in my project vs other options available.

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}

code:

package main

import (
	"fmt"
)

// left ptr, right ptr to start from beginning and end resp
// compute and compare the squares
// choose the lareger val and append to result.

func sortedSquare(nums []int) []int {
	n := len(nums)
	result := make([]int, n)

	l, r := 0, n-1

	for i := n - 1; i >= 0; i-- {
		lSquare := nums[l] * nums[l]
		rSquare := nums[r] * nums[r]

		// compute and compare
		if lSquare > rSquare {
			result[i] = lSquare
			l++
		} else {
			result[i] = rSquare
			r--
		}
	}
	return result

}
func main() {
	nums1 := []int{-4, -1, 0, 3, 10} res = [0, 1, 9, 16, 100]
	nums2 := []int{-8, -1, 0, 4, 7}  // res = [0,1,16,49,64]
	nums3 := []int{-10, 0, 1, 2, 11} // res = [0, 1, 4, 100, 121]
	out1 := sortedSquare(nums1)
	out2 := sortedSquare(nums2)
	out3 := sortedSquare(nums3)
	fmt.Println(out1)
	fmt.Println(out2)
	fmt.Println(out3)
}

[Update] Not selected.

Comments (1)