FastPrepKeep Endpoints and Strict Local Maxima
Problems/Keep Endpoints and Strict Local Maxima

Keep Endpoints and Strict Local Maxima

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two ZipRecruiter new-grad OA reports describe keeping the endpoints, including only strict interior local maxima, keeping the original order, and the example [1,2,1]. We supplied the empty and single-element cases and limits. Our version is about 96% the same as the reported questions.

Return selected values in original order. Always keep the first and last values. Keep an interior value only when it is strictly greater than both immediate neighbors.

An empty array returns empty, and a singleton is returned once.

Function

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

Examples

Example 1

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

The strict interior peak joins both endpoints.

Example 2

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

Only the endpoints remain.

Constraints

  • 0 <= values.length <= 100000
  • -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

  • Build the Task HierarchyPendo · OA
  • Missing IntervalsIBM · OAIBM interview questions
  • Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Two SumAmazon · OA · PHONE SCREEN
  • Competition Winner and Runner-Up (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Find Words That Can Be Formed by CharactersTabaPay · OA
  • Server InvestmentRippling · OARippling 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[] keepLocalMaxima(int[] values) {
        // Write your code here.
    }

}
Checking account…