FastPrepLongest Run of Ones
Problems/Longest Run of Ones

Longest Run of Ones

Adobe logoAdobe● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You find the longest unbroken block of 1s in an array of 0s and 1s. An Adobe report from a product intern hired through a 2024 on-campus drive (posted August 2024, selected) names this classic task by its usual title. It was the opening coding problem of the only interview, which lasted about 50 minutes and came after an online test. The report gives the title only, with no limits or examples.

The rules are those of the named task. We chose these limits: up to 10^4 values. We wrote new examples.

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

You are given an array nums that holds only 0s and 1s.

Return the length of the longest block of 1s that sit next to each other with no 0 between them. If the array has no 1, return 0.

Function

longestOnesRun(nums: int[]) → int

Examples

Example 1

nums = [1,1,1,0,0,1,1,0]return = 3

The runs of 1s have lengths 3 (at the start) and 2. The longest is 3.

Example 2

nums = [0,0,0]return = 0

There is no 1 at all, so the longest run has length 0.

Example 3

nums = [1,0,1,0,1,1,1,1]return = 4

The runs have lengths 1, 1 and 4. The longest run is the one that reaches the end of the array.

Constraints

  • 1 <= nums.length <= 10^4
  • Each nums[i] is 0 or 1

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

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Best Stock Trade with Buy and Sell DaysGoogle · PHONE SCREENGoogle interview questions
  • Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Total Years of Work ExperienceLinkedIn · PHONE SCREENLinkedIn interview questions
  • Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
  • Find Unique ElementsCisco · PHONE SCREENCisco interview questions
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions

Interview reports that mention this question

  • Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)
  • Adobe Intern Interview Questions: 54 Experiences (Part 1 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
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int longestOnesRun(int[] nums) {
        // Write your code here.
    }
}
Checking account…