FastPrepPeak Elements in Removal Order
Problems/Peak Elements in Removal Order

Peak Elements in Removal Order

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes finding peaks, deleting them, and returning the values in deletion order. We supplied rules for endpoints, equal values, recomputing, and choosing a peak so the result is fixed. Our version is about 82% the same as the reported question.

Repeatedly remove one peak from the current array until it is empty. An interior element is a peak when it is not smaller than either current neighbor. An endpoint is a peak when it is not smaller than its only neighbor, and the sole remaining element is a peak.

At each step remove the leftmost current peak. Return the removed values in order.

Function

removePeaks(values: int[]) → int[]

Examples

Example 1

values = [1,3,2,4]return = [3,4,2,1]

Peaks are recomputed after each leftmost removal.

Example 2

values = [7]return = [7]

The sole element is a peak.

Constraints

  • 0 <= values.length <= 2000
  • -1000000000 <= values[i] <= 1000000000

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Stabilize Student Test ScoresVirtu Financial · OAVirtu Financial interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Index of the Maximum After Left RotationsChubb · OAChubb interview questions
  • Leaves Remaining After WindCresta · OACresta interview questions
  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int[] removePeaks(int[] values) {
        // Write your code here.
    }

}
Checking account…