Using the knowledge in computational language in JAVA it is possible to write a code that an natural subsequence occurs.
import java.util.*;
class Main{
static int mn = -2147483648;
public static int longestSeq(String s)
{
int []dp = new int[30];
Arrays.fill(dp, 0);
int N = s.length();
int lis = mn;
for(int i = 0; i < N; i++)
{
int val = (int)s.charAt(i) - 97;
int curr = 0;
for(int j = 0; j < val; j++)
{
curr = Math.max(curr, dp[j]);
}
curr++;
lis = Math.max(lis, curr);
dp[val] = Math.max(dp[val], curr);
}
return lis;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
System.out.print(longestSeq(s));
}
}
See more about JAVA at brainly.com/question/12975450
#SPJ1