Infosys Interview Question

solve the subsequence varient problem.