Minimize the number of strictly increasing subsequences in an array | Set 2 | Java program to implement the above approach ; Function to find the number of strictly increasing subsequences in an array ; Sort the array ; Stores final count of subsequences ; Traverse the array ; Stores current element ; Stores frequency of the current element ; Count frequency of the current element ; If current element frequency is greater than count ; Print the final count ; Driver Code ; Given array ; Size of the array ; Function call to find the number of strictly increasing subsequences
import java . util . * ; class GFG { static void minimumIncreasingSubsequences ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int count = 0 ; int i = 0 ; while ( i < N ) { int x = arr [ i ] ; int freqX = 0 ; while ( i < N && arr [ i ] == x ) { freqX ++ ; i ++ ; } count = Math . max ( count , freqX ) ; } System . out . print ( count ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 1 , 2 , 1 , 4 , 3 } ; int N = arr . length ; minimumIncreasingSubsequences ( arr , N ) ; } }