
Asked in Flipkart
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...
Top Software Developer Intern Interview Questions Asked at Flipkart
Q. Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]]...read more
Q. Given a matrix, if an element is 0, set its entire row and column to 0.
Q. Design a parking lot application for blind people.
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Flipkart Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
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

