Number of Longest Increasing Subsequence Problem Statement

Given an integer array ARR of length N, determine the count of longest increasing subsequences present in the array.

Explanation:

The Longest Increasing Subsequence (LIS) is the longest subsequence in the given sequence where the subsequence elements appear in an increasing order.

The subsequence should strictly increase, meaning each subsequent number must be greater than its predecessor.

Example:

Input:
ARR = [50, 3, 90, 60, 80]
Output:
2
Explanation:

In this example, the longest increasing subsequences are [50, 60, 80] and [3, 60, 80]. Therefore, the output is 2, as there are two longest increasing subsequences.

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ N ≤ 2000
  • 1 ≤ ARR[i] ≤ 10^6
  • Time limit: 1 second
Note:
You need to implement the function only; handling of input/output is already managed.
Be the first one to answer
Add answer anonymously...
Tata 1mg Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter