FastPrepFirst Value Below Both Neighbors
Problems/First Value Below Both Neighbors

First Value Below Both Neighbors

Capital One logoCapital One● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report asks for the first array element whose two neighbors are both strictly larger. We chose to return the element value, to leave out the two end elements, the value to return when there is none, and the number limits.

Given an integer array nums, inspect its interior elements from left to right. Return the value of the first element whose immediate left and right neighbors are both strictly larger.

Return -1 when no such interior element exists. The first and last elements are not eligible because they do not have two adjacent neighbors.

Function

firstValleyValue(nums: int[]) → int

Examples

Example 1

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

The value 3 is below both 8 and 5. Although 2 is also below both neighbors, it appears later.

Example 2

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

The only interior value is not below either neighbor.

Example 3

nums = [5,1,1,5]return = -1

Equal adjacent values do not satisfy the strict comparison.

Constraints

  • 3 <= nums.length <= 10^5.
  • 0 <= nums[i] <= 10^9.

More Capital One Online Assessment questions

  • Rank Football TeamsOA · Seen Oct 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Oct 2026
  • Arithmetic Triplets After QueriesOA · Seen Oct 2026
  • Branch with the Most FilesOA · Seen Oct 2026
  • Count One-Swap Number PairsOA · Seen Oct 2026
  • Distinct Values on Maximum-Sum FramesOA · Seen Oct 2026
  • Earliest Meeting Time for All EmployeesOA · Seen Oct 2026
  • Earn the Most 🐝OA · Seen Oct 2026
  • Sort Adjacent PairsOA · Seen Oct 2026
  • Bouncing Diagonal WeightsOA · Seen Oct 2026

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Book Reading EveningsGoogle · OAGoogle interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
  • Shell Command Counts with History ReferencesTikTok · OATikTok interview questions
  • Count Dropped RequestsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Recursively Expanded Shell Command CountsHudson River Trading · OAHudson River Trading interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Tool ChangerIBM · OAIBM interview questions

Interview reports that mention this question

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences

Capital One interview experiences

  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int firstValleyValue(int[] nums) {
        // Write your code here.
    }
}
Checking account…