FastPrepSmallest and Largest in a Rotated Sorted Array
Problems/Smallest and Largest in a Rotated Sorted Array

Smallest and Largest in a Rotated Sorted Array

Adobe logoAdobe● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You find the smallest and the largest value of a sorted array that has been rotated. The source is one report, posted in January 2022, on Adobe's SheCodes 2021 internship hiring. The author felt their coding answers worked but were not the most efficient. This task was the last of three coding questions. The interview came after a CV screen and an online test. The report gives the task in a single line. It does not say whether values can repeat, and it has no limits or examples.

We chose these rules. All values are different. The array is an increasing array rotated by an unknown amount, possibly zero. The answer is the pair [smallest, largest]. There are 1 to 5000 values, from -10^9 to 10^9. We wrote new examples. The tests check only the pair, so a linear scan also passes. The editorial teaches the logarithmic search.

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

An array of different integers was put 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 [6,13,29,44,58,71] with k = 3 gives [44,58,71,6,13,29]. With k = 0 the array stays sorted.

You are given the rotated array nums, but not k. Return a list of two numbers: the smallest value in nums, then the largest value.

Function

minAndMax(nums: int[]) → int[]

Examples

Example 1

nums = [44,58,71,6,13,29]return = [6,71]

The sorted array [6,13,29,44,58,71] was rotated so that it starts at 44. The smallest value, 6, sits at index 3, and the largest, 71, sits right before it at index 2.

Example 2

nums = [-8,-2,5,11]return = [-8,11]

The array was not rotated at all, so the smallest value is the first element and the largest is the last.

Example 3

nums = [9,-4]return = [-4,9]

Two values with the drop between them: the smallest is -4 (index 1) and the largest is 9 (index 0).

Constraints

  • 1 <= nums.length <= 5000
  • -10^9 <= nums[i] <= 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 Product Intern Interviews: 15 Experiences (Part 3 of 4)

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 New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int[] minAndMax(int[] nums) {
        // Write your code here.
    }
}
Checking account…