Grokking Advanced Coding Patterns for Interviews
Ask Author
Back to course home

0% completed

Solution: Number of Longest Increasing Subsequence

Problem Statement

Given an integer array nums, return the number of longest increasing subsequences.

A subsequence is derived from the array by deleting some or no elements without changing the order of the remaining elements

Note: Sequences should be strictly increasing.

Examples

  1. Example 1:

    • Input: nums = [2, 6, 4, 3, 5]
    • Expected Output: 2
    • Explanation: The longest increasing subsequences are [2, 3, 5] and [2, 4, 5], both having a length of 3. Therefore, there are two such subsequences.
  2. Example 2:

    • Input: nums =

.....

.....

.....

Like the course? Get enrolled and start learning!