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

Search a Rotated Sorted Array

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You find where a value sits in a sorted array that has been rotated. Two Adobe reports name this classic task by its usual title. The first is a post by a CS 1 candidate in Noida, India with three years of experience (October 2023, rejected). There it is the second of seven items in one interview of about 80 minutes. Most other items were concept questions on singletons, critical sections, pagination and threads, plus one tree-path task. The author says their answer was a binary search. The second is a report by an SDE 1 fresher hired on campus (interview August 2022, selected). There it is the only coding question of the first live interview, a 50-minute face-to-face round after an online test. That author rates binary search as the best approach, ahead of sorting first or scanning for the sorted stretch. Neither report gives limits or examples.

The rules are those of the named task. We chose these limits: up to 5000 values, from -10^9 to 10^9. We wrote new examples. The tests check only the returned index, so a linear scan also passes. The editorial teaches the logarithmic search.

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

An array of different integers was sorted in increasing order and then rotated: its first k elements, for some k with 0 <= k < n, were moved in the same order to the end. For example, rotating [3,9,17,25,31,40,52] with k = 4 gives [31,40,52,3,9,17,25]. With k = 0 the array stays sorted.

You are given the rotated array nums (but not k) and a value target. Return the index of target in nums, or -1 if it is not in the array.

Function

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

Examples

Example 1

nums = [31,40,52,3,9,17,25]target = 9return = 4

The sorted array [3,9,17,25,31,40,52] was rotated so that it starts at 31. The value 9 sits at index 4.

Example 2

nums = [12,18,2,5]target = 13return = -1

13 is between 12 and 18 in value, but it is not in the array, so the answer is -1.

Example 3

nums = [-6,-1,4,10]target = 10return = 3

The array is not rotated at all (rotation by 0). 10 is the last element, index 3.

Constraints

  • 1 <= nums.length <= 5000
  • -10^9 <= nums[i], target <= 10^9
  • All values in nums are different, and nums is an increasing array rotated by some k with 0 <= k < nums.length

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • 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
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Longest Increasing SubsequenceAngel One · PHONE SCREEN
  • Aggressive CowsAmazon · PHONE SCREEN
  • Find First and Last Position of Element in Sorted ArrayEPAM · PHONE SCREENEPAM interview questions
  • Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN
  • Search in Rotated Sorted ArrayZoomInfo · PHONE SCREEN
  • Find a Peak ElementFox Corporation · PHONE SCREEN

Interview reports that mention this question

  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe CS1 Interviews: 14 Experiences (Part 4 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int searchRotated(int[] nums, int target) {
        // Write your code here.
    }
}
Checking account…