FastPrepSearch a Rotated Sorted Array
Problems/Search a Rotated Sorted Array

Search a Rotated Sorted Array

NVIDIA logoNVIDIA● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an NVIDIA phone screen for a new grad role. The report names the well-known rotated-array search and says running time was not required. We chose that values are distinct, the index convention, what happens when the target is absent, and the limits.

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

An integer array nums has distinct values. It was sorted in strictly increasing order, then possibly rotated without changing the circular order.

Return the zero-based index of target, or -1 when it is absent. The array may also remain in its original sorted order.

Function

search(nums: int[], target: int) → int

Examples

Example 1

nums = [4,5,6,7,0,1,2]target = 0return = 4

The target occurs at zero-based index 4.

Example 2

nums = [4,5,6,7,0,1,2]target = 3return = -1

The target does not occur in either sorted segment.

Example 3

nums = [1]target = 0return = -1

The only value differs from the target.

Constraints

  • 1 <= nums.length <= 5000.
  • -10^4 <= nums[i], target <= 10^4.
  • All values are distinct; nums is a rotation of an increasing array.

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Single Element in a Sorted ArrayGreyOrange · PHONE SCREENGreyOrange interview questions
  • Count Winning Dice Face PairsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Search in a Rotated Sorted ArrayAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
  • Koko Eating BananasThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Find First and Last Position in a Sorted ArrayInstacart · PHONE SCREENInstacart interview questions
  • Longest Increasing SubsequenceAngel One · PHONE SCREEN
  • Search a 2D MatrixWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Find First and Last Position of Element in Sorted ArrayEPAM · PHONE SCREENEPAM interview questions
  • Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public int search(int[] nums, int target) {
        return -1;
    }
}
Checking account…