Longest Decreasing Subsequence Problem Statement
Given an array/list of integers ARR
consisting of N
integers, your task is to determine the length of the longest decreasing subsequence.
Explanation:
A subsequence is a sequence derived by deleting zero or more elements from the array/list without changing the order of the remaining elements. A decreasing subsequence is one where each subsequent element is strictly less than the previous element.
Input:
T: Integer, number of test cases
N: Integer, size of array/list for each test case
ARR: List of integers, each representing elements of the array/list
Output:
For each test case, output the length of the longest decreasing subsequence.
Separate each test case result with a new line.
Example:
Input:
1
5
[5, 0, 3, 2, 9]
Output:
3
Explanation:
For the given array [5, 0, 3, 2, 9], the longest decreasing subsequence is of length 3, e.g., [5, 3, 2].
Constraints:
1 ≤ T ≤ 50
1 ≤ N ≤ 5000
1 ≤ ARR[i] ≤ 10^9
- Time Limit: 1 sec
Note:
There can be more than one subsequence with the longest length.
Attempt to solve the problem in O(N log N) time complexity.

AnswerBot
4mo
Find the length of the longest decreasing subsequence in an array of integers.
Use dynamic programming to keep track of the length of the longest decreasing subsequence ending at each index.
Initialize ...read more
Help your peers!
Add answer anonymously...
Flipkart Software Developer Intern interview questions & answers
A Software Developer Intern was asked 2mo agoQ. Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]...read more
A Software Developer Intern was asked 12mo agoQ. Given a matrix, if an element is 0, set its entire row and column to 0.
A Software Developer Intern was asked Q. Design a parking lot application for blind people.
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked 2mo agoQ1. Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]...read more
A Software Developer Intern was asked 12mo agoQ2. Given a matrix, if an element is 0, set its entire row and column to 0.
A Software Developer Intern was asked Q3. Design a parking lot application for blind people.
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

