FastPrepSquares of a Sorted Array
Problems/Squares of a Sorted Array

Squares of a Sorted Array

Goldman Sachs logoGoldman Sachs● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: A Goldman Sachs CoderPad report links the well-known Squares of a Sorted Array exercise. It says the final follow-up required linear time with constant extra space. The report does not give the function signature or the full constraints. Our version is about 99% the same as the reported question.

Given an integer array nums sorted in nondecreasing order, square every value and return the resulting values in nondecreasing order.

Function

sortedSquares(nums: int[]) → int[]

Examples

Example 1

nums = [-4,-1,0,3,10]return = [0,1,9,16,100]

Example 2

nums = [-7,-3,2,3,11]return = [4,9,9,49,121]

More Goldman Sachs Phone Screen questions

  • House Robber IIIPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count Staircase WaysPHONE SCREEN · Seen Oct 2026
  • Is a Power of TenPHONE SCREEN · Seen Oct 2026
  • Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
  • Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Squares of a Sorted ArrayInstacart · PHONE SCREENInstacart interview questions
  • Assign CookiesAmazon · PHONE SCREEN
  • Merge Two Sorted ArraysCapgemini · PHONE SCREENCapgemini interview questions
  • Squares of a Sorted ArrayStryker · PHONE SCREEN
  • Merge Into the Zero-Padded ArrayAdobe · PHONE SCREENAdobe interview questions
  • Three Partition ArrayMicrosoft · PHONE SCREENMicrosoft interview questions
  • Sorted Squares in Descending OrderWhatNot · PHONE SCREENWhatNot interview questions
  • Assign CookiesExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
  • Merge Two Sorted ArraysZillow · PHONE SCREENZillow interview questions
  • Merge Sorted Arrays with DuplicatesMygate · PHONE SCREENMygate interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int[] sortedSquares(int[] nums) {
      // write your code here
    }
}
Checking account…