Longest increasing sub | Java implementation to find the longest increasing subsequence in repeating element of array ; Function to find the LCS ; Loop to create frequency array ; Driver code
import java . util . * ; class GFG { static int findLCS ( int arr [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } return mp . size ( ) ; } public static void main ( String [ ] args ) { int n = 3 ; int arr [ ] = { 3 , 2 , 1 } ; System . out . print ( findLCS ( arr , n ) ) ; } }