Print All Longest Increasing Subsequences

1. You are given a number N representing number of elements.
2. You are given N space separated numbers (ELE : elements).
3. Your task is to find & print
3.1) Length of "Longest Increasing Subsequence"(LIS).
3.2) All "Longest Increasing Subsequence(s)"(LIS).
NOTE: Checkout sample question/solution video inorder to have more insight.
Input Format
A number N (representing "NUMBER OF ELEMENTS").
ELE1 ,ELE2 ,ELE3 ,ELE4 .... ELEn (N space separated numbers represnting numbers).
Output Format
1) A number representing Length of "Longest Increasing Subsequence"(LIS).
2) Strings representing "Longest Increasing Subsequence(s)"(LIS).
Check the sample ouput and question video.
Question Video
Constraints
1 <= N <= 100
1 <= ELE <= 1000
Sample Input
10
10 22 9 33 21 50 41 60 80 1
Sample Output
6
10 -> 22 -> 33 -> 41 -> 60 -> 80
10 -> 22 -> 33 -> 50 -> 60 -> 80


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name