Count Valleys in a Wiggle Pattern
Updated
Problem statement
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[]) → intExamples
Example 1
nums = [5,1,4,2,3]return = 2Indices 1 and 3 are strict valleys.
Example 2
nums = [1,2,3]return = 0The 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
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