Longest increasing sub | C ++ implementation to find the longest increasing subsequence in repeating element of array ; Function to find the LCS ; Loop to create frequency array ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findLCS ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { mp [ arr [ i ] ] ++ ; } return mp . size ( ) ; } int main ( ) { int n = 3 ; int arr [ ] = { 3 , 2 , 1 } ; cout << findLCS ( arr , n ) ; return 0 ; }