FastPrepCount Valleys in a Wiggle Pattern
Problems/Count Valleys in a Wiggle Pattern

Count Valleys in a Wiggle Pattern

CoinDCX logoCoinDCX● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a CoinDCX phone screen. The report asks for counting valleys in a wiggle pattern. We chose whether the comparison is strict, what happens at the two ends, and the limits. Our version is about 86% the same as the reported question.

A valley is an interior index whose value is strictly smaller than both adjacent values.

Return the number of valleys in nums. Endpoints are never valleys, and equal neighbors do not form a strict valley.

Function

countValleys(nums: int[]) → int

Examples

Example 1

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

Indices 1 and 3 are strict valleys.

Example 2

nums = [1,2,3]return = 0

The sequence has no valley.

Constraints

  • 0 <= nums.length <= 100000.
  • -10^9 <= nums[i] <= 10^9.

Source note: Author-written prompt excerpt retained for source fidelity.

More CoinDCX Phone Screen questions

  • DFS Subsequences of a String (For MLE)PHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
  • Paginate Retained Conversation HistorySierra · PHONE SCREENSierra interview questions
  • Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
  • Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
  • Bounded IPv4 FilterAmazon · PHONE SCREEN
See CoinDCX hiring insights
Saved
class Solution {
    public int countValleys(int[] nums) {
        // Write your code here.
    }
}
Checking account…