Print All Longest Increasing Subsequences

easy
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.

Constraints

1 <= N <= 100
1 <= ELE <= 1000

Example

Input
10
10 22 9 33 21 50 41 60 80 1
Output
6
10 -> 22 -> 33 -> 41 -> 60 -> 80
10 -> 22 -> 33 -> 50 -> 60 -> 80
Previous
Print All Paths With Minimum Jumps
Next
Print All Results In 0-1 Knapsack

Related Questions