Length of Smallest Non Prime Subsequence in given numeric String | Function to find the smallest length of resultant subsequence ; Check for a subsequence of size 1 ; Check for a subsequence of size 2 ; If none of the above check is successful then subsequence must be of size 3 ; Never executed ; Driver Code
function findMinimumSubsequence ( S ) { let flag = false ; for ( let j = 0 ; j < S . length ; j ++ ) { if ( S [ j ] != ' ' && S [ j ] != ' ' && S [ j ] != ' ' && S [ j ] != ' ' ) { document . write ( 1 ) ; flag = true ; break ; } } if ( flag == false ) { for ( let j = 0 ; j < S . length ; j ++ ) { for ( let j1 = j + 1 ; j1 < S . length ; j1 ++ ) { let dummy = S [ j ] + S [ j1 ] ; if ( dummy != " " && dummy != " " && dummy != " " && dummy != " " ) { document . write ( 2 ) ; } if ( flag == true ) break ; else flag = true ; } if ( flag == true ) break ; } } if ( flag == false ) { if ( S . length >= 3 ) { document . write ( 3 ) ; } else { document . write ( - 1 ) ; } } } let S = " " ; findMinimumSubsequence ( S ) ;