Maximum product of an increasing subsequence | Dynamic programming C # implementation of maximum product of an increasing subsequence ; Returns product of maximum product increasing subsequence . ; Initialize MPIS values ; Compute optimized MPIS values considering every element as ending element of sequence ; Pick maximum of all product values ; Driver program to test above function
using System ; using System . Linq ; public class GFG { static long lis ( long [ ] arr , long n ) { long [ ] mpis = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) mpis [ i ] = arr [ i ] ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && mpis [ i ] < ( mpis [ j ] * arr [ i ] ) ) mpis [ i ] = mpis [ j ] * arr [ i ] ; return mpis . Max ( ) ; } static public void Main ( ) { long [ ] arr = { 3 , 100 , 4 , 5 , 150 , 6 } ; long n = arr . Length ; Console . WriteLine ( lis ( arr , n ) ) ; } }