FastPrepCount Bowl Subarrays
Problems/Count Bowl Subarrays

Count Bowl Subarrays

PhonePe logoPhonePe● MediumONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by a real PhonePe onsite interview report. The report linked the exact Count Bowl Subarrays task, but it did not reproduce the rules, function interface, examples, or constraints. The core task match is about 95%.

You are given an integer array nums with distinct elements.

A subarray nums[l...r] is a bowl when:

  • Its length is at least 3.
  • The smaller of its two endpoint values is strictly greater than every value between the endpoints.

Return the number of bowl subarrays.

Function

bowlSubarrays(nums: int[]) → long

Examples

Example 1

nums = [2,5,3,1,4]return = 2

The bowl subarrays are [3,1,4] and [5,3,1,4].

Example 2

nums = [5,1,2,3,4]return = 3

The valid bowl subarrays are [5,1,2], [5,1,2,3], and [5,1,2,3,4].

Constraints

  • 3 <= nums.length <= 10^5
  • 1 <= nums[i] <= 10^9
  • nums contains distinct values.

More PhonePe interview questions

  • Maximum Sum with K-Element SkippingONSITE INTERVIEW · Seen Dec 2026
  • Minimum Number of Days to Make m BouquetsONSITE INTERVIEW · Seen Dec 2026
  • Evaluate DivisionONSITE INTERVIEW · Seen Oct 2026
  • K-th Smallest Value in a Sorted MatrixONSITE INTERVIEW · Seen Oct 2026
  • Identify Two Failing Tests From an Oracle TranscriptONSITE INTERVIEW · Seen Sep 2026
  • Reconstruct ItineraryONSITE INTERVIEW · Seen Jul 2026
  • Constrained Jump SequencesOA · Seen Aug 2026
  • Maximum Payout with Context SwitchesOA · Seen Aug 2026
  • Substrings Without a Target SubsequenceOA · Seen Aug 2026
  • Luna and the Colorful SocksOA · Seen Jul 2026

Similar questions at other companies

  • Generic Stack Operation SequenceArista Networks · PHONE SCREEN · ONSITE INTERVIEWArista Networks interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Fountain SafetyGoogle · ONSITE INTERVIEWGoogle interview questions
  • Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Next Smaller Ticket PriceAmazon · ONSITE INTERVIEW
  • Next Greater Element to the RightTekion · ONSITE INTERVIEWTekion interview questions
  • Surviving Balls after Directional CollisionsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Daily TemperatureseBay · ONSITE INTERVIEWeBay interview questions
  • Asteroid CollisionAdobe · ONSITE INTERVIEWAdobe interview questions
All PhonePe interview questionsSee PhonePe hiring insights
Saved
class Solution {
    public long bowlSubarrays(int[] nums) {
      // write your code here
    }
}
Checking account…