Split Array Into Increasing Subsequences Problem Statement

You are provided with an integer array ARR of size N sorted in ascending order. Your task is to determine if it is possible to split this array into one or more increasing subsequences such that each subsequence is made up entirely of consecutive integers and has a minimum length of three. If yes, return 1; otherwise, return 0.

Explanation:

An increasing sequence is defined as a sequence where the difference between each subsequent element is exactly 1. For example, sequences like [1, 2, 3, 4], [3, 4, 5], or [-1, 0, 1] are considered increasing subsequences.

Input:

The input consists of:

The first line contains an integer T, the number of test cases.

The first line of each test case contains a single integer N, the number of elements in the array 'ARR'.

The second line of each test case contains N space-separated integers, representing the elements of 'ARR'.

Output:

For each test case, output a single line containing 1 if the array can be split into subsequences where each subsequence comprises consecutive integers with a length of at least 3. Otherwise, output 0.

Example:

Input:
T = 1
N = 4
ARR = [1, 2, 3, 4]
Output:
1
Explanation:

The array [1, 2, 3, 4] can be split into an increasing subsequence of itself, which has a length greater than 3.

Constraints:

  • 1 ≤ T ≤ 5
  • 1 ≤ N ≤ 5000
  • -1250 ≤ ARR[i] ≤ 1250

Note: The function implementation does not require explicit printing of the result; it is managed internally.

AnswerBot
1y

The task is to determine if an integer array can be split into one or more increasing subsequences with a length of at least 3.

  • Check if the array can be split into increasing subsequences by iterating...read more

Help your peers!
Select
Add answer anonymously...

ACKO Software Developer interview questions & answers

A Software Developer was asked 12mo agoQ. How would you sort numbers in a large file?
A Software Developer was asked 12mo agoQ. Design a parking lot.
A Software Developer was asked Q. Flip Equivalent Binary Tree Problem Determine whether two binary trees, given by...read more

Popular interview questions of Software Developer

A Software Developer was asked 12mo agoQ1. How would you sort numbers in a large file?
A Software Developer was asked 12mo agoQ2. Design a parking lot.
A Software Developer was asked Q3. Flip Equivalent Binary Tree Problem Determine whether two binary trees, given by...read more
ACKO Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits