FastPrepTwo Non-Overlapping Increasing Blocks
Problems/Two Non-Overlapping Increasing Blocks

Two Non-Overlapping Increasing Blocks

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem asks whether an array holds two separate rising blocks of a given length k, and also for the longest length at which two separate rising blocks still exist. An Adobe MTS 2 (Java) report lists both parts, one after the other, as the coding questions of its first problem-solving round, with no examples, limits or edge rules.

Our choices: rising means each value strictly larger than the one before, the two blocks need not be next to each other, one function returns both answers as [0 or 1, longest length], at most 20000 values, and new examples.

The judged task matches the report at about 75%.

A block is a run of consecutive positions of nums. It is increasing when every value is strictly larger than the one before it (a block of one value counts as increasing). Two blocks do not overlap when no position belongs to both; they do not have to be next to each other.

Return [fitsK, best], where:

  • fitsK is 1 if nums has two non-overlapping increasing blocks of length k, otherwise 0;
  • best is the largest length L for which nums has two non-overlapping increasing blocks of length L.

Function

twoIncreasingBlocks(nums: int[], k: int) → int[]

Examples

Example 1

nums = [1,3,5,2,4,6,8,0]k = 3return = [1,3]

[1, 3, 5] (positions 0 to 2) and [2, 4, 6] (positions 3 to 5) are both increasing and share no position, so length 3 works. Length 4 fails: the only increasing block of 4 is [2, 4, 6, 8], and nothing else of length 4 is increasing. So the answer is [1, 3].

Example 2

nums = [5,6,7,8,9,10,11]k = 4return = [0,3]

The whole array increases, but two blocks of 4 need 8 positions and there are only 7. Splitting it gives two blocks of 3, for example [5, 6, 7] and [8, 9, 10]. The answer is [0, 3].

Example 3

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

Equal neighbours are not increasing, so no block longer than 1 works. Any single value counts as increasing, and two single values never overlap: [1, 1].

Constraints

  • 2 <= nums.length <= 20000
  • -10^9 <= nums[i] <= 10^9
  • 1 <= k <= nums.length

More Adobe problems

  • 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
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[] twoIncreasingBlocks(int[] nums, int k) {
    // Write your code here.
}
Checking account…