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

Search in a Rotated Sorted Array

Akuna Capital logoAkuna Capital● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Akuna Capital intern phone screens. The task is to search a rotated sorted array, including a version that returns the index of the target. The reports leave out some details, so we fixed them: values are distinct, we set the input limits, and we decided what happens with empty input and with a missing target. Our version is about 95% the same as the reported question.

You are given an integer array nums with distinct values. It was sorted in strictly increasing order, then rotated by moving a prefix to the end. A rotation by zero positions is allowed.

For example, [1,2,3,4,5,6] can become [5,6,1,2,3,4].

Return the zero-based index of target, or -1 if it is absent. Return -1 for an empty array. Find an O(log(n + 1))-time solution.

Function

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

Examples

Example 1

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

The value 2 occurs at index 3 in the rotated array.

Example 2

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

The array contains no value equal to 7.

Example 3

nums = []target = 0return = -1

The empty array has no target index.

Constraints

  • 0 <= nums.length <= 100000
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9
  • All values in nums are distinct.
  • nums is a rotation of a strictly increasing array.

More Akuna Capital Phone Screen questions

  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Sep 2026
  • Maximum Value in a Binary TreePHONE SCREEN · Seen Sep 2026
  • Tiered Expiring Item StorePHONE SCREEN · Seen Aug 2026
  • Statistics for the Latest K ValuesPHONE SCREEN · Seen Nov 2025
  • Remove Duplicates While Preserving OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
  • Sliding Window MaximumPHONE SCREEN · Seen Oct 2025
  • Evaluate a PolynomialPHONE SCREEN · Seen Oct 2025

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

  • Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)
  • Akuna Capital QR Screens and Coding: 77 Experiences (Part 1 of 6)

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int searchRotated(int[] nums, int target) {
        // write your code here
    }
}
Checking account…