FastPrepCount Increasing Stock Periods
Problems/Count Increasing Stock Periods

Count Increasing Stock Periods

Expedia logoExpedia● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a sliding window task. Given an array of stock prices, find the number of k-month strictly increasing subarrays.

The report gives no examples or limits and does not define a k-month subarray. Here, a period is exactly k consecutive months, not k or more. Periods may overlap, a one-month period always counts, and k is never larger than the array. The function shape, the examples, and the limits are our choices, not from the report.

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

You are given an integer array stockPrices, where stockPrices[i] is the stock price in month i, and an integer k.

A period is a run of exactly k consecutive months. A period counts when every month after its first has a price strictly higher than the month before it.

  • An equal price does not count as a rise.
  • A period of one month has nothing to compare, so it always counts.
  • Periods may overlap. Periods that start in different months are different periods.

Return the number of periods that count.

Function

countIncreasingPeriods(stockPrices: int[], k: int) → int

Examples

Example 1

stockPrices = [10,20,30,40,20,30]k = 3return = 2

The four periods of 3 months are [10,20,30], [20,30,40], [30,40,20], and [40,20,30]. Only the first two rise every month. They overlap, and each one counts.

Example 2

stockPrices = [5,5,6,7]k = 2return = 2

The periods are [5,5], [5,6], and [6,7]. In [5,5] the price stays the same, so it does not count. The other two count.

Example 3

stockPrices = [4,3,2]k = 1return = 3

With k = 1, each period is a single month with nothing to compare, so all 3 months count.

Example 4

stockPrices = [7,9,8,10]k = 3return = 0

The periods are [7,9,8] and [9,8,10]. Each has a drop from 9 to 8, so neither counts, even though each one ends higher than it starts.

Constraints

  • 1 <= k <= stockPrices.length <= 10^5
  • 1 <= stockPrices[i] <= 10^9

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024
  • Longest Subsequence That Is a SubstringOA · Seen Oct 2024

Similar questions at other companies

  • Count Strictly Increasing Contiguous WindowsIBM · OAIBM interview questions
  • Count Good TuplesMatroid · OA
  • Find Sliding-Window Pattern Start IndicesVisa · OAVisa interview questions
  • Minimum Parking Roof LengthAmerican Express · OAAmerican Express interview questions
  • Threshold AlertsGoldman Sachs · OAGoldman Sachs interview questions
  • Maximum Events in a 60-Second WindowMarshall Wace · OAMarshall Wace interview questions
  • Maximum Value of L (For off-campus 2025 batch hiring :)Uber · OAUber interview questions
  • Optimizing Resource AllocationDell Technologies · OADell Technologies interview questions
  • Reduce Memory UsageAmazon · OA
  • Earliest Longest Bounded-Adjacent SubarrayZipRecruiter · OAZipRecruiter interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Interviews: 20 Experiences (Part 1 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int countIncreasingPeriods(int[] stockPrices, int k) {
        // Write your code here.
    }
}
Checking account…