FastPrepCount Later Lower Readings
Problems/Count Later Lower Readings

Count Later Lower Readings

Rippling logoRippling● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our choices for this exercise: a story about hourly sensor readings, new examples, 1 to 3,000 readings with values from -1,000,000,000 to 1,000,000,000, and a rule that a later reading counts only when it is strictly lower, so equal readings never count. We cap the length at 3,000 to keep the printed answer small. At this size a plain double loop also passes.

The source is a post from November 23, 2022, about an on-campus SDE offer in Bangalore for a 2023 graduate. For the second of its two rounds the post lists two questions. The first is given only as a link to a public problem that asks, for every number, how many smaller numbers come after it. The second is described only by its topics, greedy choices and binary search. It is not part of this exercise. The post gives no statement text, examples or limits for either one.

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

A sensor stores one reading per hour, in order, in the array nums. For each hour i, count the hours j with j > i whose reading is strictly lower: nums[j] < nums[i]. A later reading equal to nums[i] does not count.

Return a list counts of the same length as nums, where counts[i] is the count for hour i.

Function

countSmaller(nums: int[]) → List<Integer>

Examples

Example 1

nums = [3,7,-2,7,5,0]return = [2,3,0,2,1,0]

After 3 come -2 and 0, which are lower: 2. After the first 7 come -2, 5 and 0: 3 (the second 7 is equal, so it does not count). After -2 nothing is lower: 0. After the second 7 come 5 and 0: 2. After 5 comes 0: 1. The last reading has nothing after it: 0.

Example 2

nums = [9,9,9]return = [0,0,0]

Every later reading is equal, not lower, so every count is 0.

Example 3

nums = [1000000000,-1000000000,0,0]return = [3,0,0,0]

All three later readings are below 1000000000, so the first count is 3. Nothing is below -1000000000. The first 0 is followed by another 0, which is equal, so its count is 0.

Constraints

  • 1 <= nums.length <= 3000
  • -10^9 <= nums[i] <= 10^9

More Rippling Onsite Interview questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delivery Cost TrackerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Maximum Currency Conversion Along a Simple PathPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent WordsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Future-Effective Employee SalaryONSITE INTERVIEW · Seen Aug 2026
  • Filter and Sort Scheduled TasksONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Operations to Make an Array ContinuousAmazon · ONSITE INTERVIEW
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Count Points in Each Boundary IntervalBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Find Unmet Users With Shared InterestsPalantir · ONSITE INTERVIEWPalantir interview questions
  • Room Occupancy at Query TimesWhatNot · ONSITE INTERVIEWWhatNot interview questions
  • HTTP Log QueriesDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Smallest Common Integer in Sorted ListsMotive · ONSITE INTERVIEWMotive interview questions
  • Sliding Window MedianAuxoAI · OA

Interview reports that mention this question

  • Rippling New Grad SDE Interviews: 11 Experiences

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 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 List<Integer> countSmaller(int[] nums) {
        // Write your code here.
    }
}
Checking account…