FastPrepSteps to the Next Higher Value in a Circle
Problems/Steps to the Next Higher Value in a Circle

Steps to the Next Higher Value in a Circle

Rippling logoRippling● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A January 2026 Rippling SDE-1 report names next greater element as the starting point of its online assessment problem. It says the problem was changed but not in what way, and gives no other detail about it.

The report gives no limits, examples or output format. The change used here is our own choice: the list wraps around, each position gets the number of steps forward to the first strictly greater value (equal values do not count), -1 means there is none, and the limits and examples are our own.

Our version is about 40% the same as the reported question.

You are given a list of integers values arranged in a circle: after the last position comes the first position again.

For each position i, start at i and move forward one position at a time, wrapping from the end to the start. Count how many steps it takes to reach a value that is strictly greater than values[i]. If no other position holds a greater value, the answer for i is -1.

Return an array answer of the same length, where answer[i] is the step count for position i.

Function

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

Examples

Example 1

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

From 3, the next higher value is 4, two steps ahead. From 1, it is 4, one step ahead. Nothing is higher than 4, so it gets -1. From the last value 2, there is nothing to its right, so wrap around to the start: 3 is one step ahead.

Example 2

values = [5,5,5]return = [-1,-1,-1]

All values are equal. An equal value is not higher, so every position gets -1.

Example 3

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

From 3 (index 3), the value 2 one step ahead is lower, then the walk wraps to 4 at index 0, which is two steps ahead. From 2 (index 4), the wrap reaches 4 after one step. 9 is the largest value, so it gets -1.

Constraints

  • 1 <= values.length <= 2000
  • -10^9 <= values[i] <= 10^9

More Rippling Online Assessment questions

  • Most Segments That Sort the ArrayOA · Seen Nov 2026
  • Palindromic Paths to the RootOA · Seen Nov 2026
  • Server InvestmentOA · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • REST API: Highest International StudentsOA · Seen Sep 2026
  • Token ValidationOA · Seen Sep 2026
  • Consistent LogsOA · Seen Sep 2026
  • Costliest ChocolateOA · Seen Sep 2026
  • Server ManagementOA · Seen Sep 2026
  • Cyber Beacon DetectionOA · Seen Aug 2026

Similar questions at other companies

  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Sum of Subarray MinimumsNVIDIA · OANVIDIA interview questions
  • Shopkeeper Final Price SummaryMicrosoft · OAMicrosoft interview questions
  • Nested Recipe Blocks (Game Adaptation)Roblox · OARoblox interview questions
  • Maximum Capped Histogram Area After One RemovalMyntra · OAMyntra interview questions
  • Shopkeeper Final PriceUber · OAUber interview questions
  • Predict AnswerAmazon · OA
  • Retention Policy CollisionBox · OABox interview questions
  • Longest Prefix-Valid Binary SubarrayHackerRank · OAHackerRank interview questions
  • Sum of Subarray RegionsPatreon · OA

Interview reports that mention this question

  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int[] stepsToNextHigher(int[] values) {
        // Write your code here.
    }
}
Checking account…