Increasing Subsegment Problem Statement
Given a sequence ARR
consisting of N
integers, your task is to identify the longest subsegment of ARR
, where you can change at most one number to make the subsegment strictly increasing.
Input:
The first line contains a single integer T representing the number of test cases.
Each test case starts with an integer 'N' (length of 'ARR').
The second line of each test case follows with 'N' space-separated integers denoting the elements of 'ARR'.
Output:
For each test case, output the length of the longest possible subsegment after changing at most one number.
Example:
Input:
2
4
1 3 2 4
5
10 20 10 30 40
Output:
4
5
Constraints:
1 <= T <= 10
1 ≤ N ≤ 105
1 ≤ ARR[i] ≤ 109
- Time Limit: 1 sec
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.

AnswerBot
4mo
Find the longest subsegment where at most one number can be changed to make it strictly increasing.
Iterate through the array and keep track of the longest increasing subsegment with at most one change...read more
Help your peers!
Add answer anonymously...
ACKO Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Given the root of a binary tree, traverse the tree using inorder, preorder, and ...read more
A Software Developer Intern was asked Q. How would you design an application like Instagram?
A Software Developer Intern was asked Q. Rat in a Maze Problem Statement Given a maze of size N * N with a rat placed at ...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Given the root of a binary tree, traverse the tree using inorder, preorder, and ...read more
A Software Developer Intern was asked Q2. How would you design an application like Instagram?
A Software Developer Intern was asked Q3. Rat in a Maze Problem Statement Given a maze of size N * N with a rat placed at ...read more
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

