KLA Interview Question

1st one is Some DP question and 2nd is a permutation question.