Problem says is Given two Strings b1,b2 we need to find Subsequence of K length such that ascii value sum of string is max given that b1,b2 are lowercase characters

My logic is i find a string common between b1 & b2 i:e Let b1 = “understand” and b2 =“uxerfd” now k =3 so common string is

“uerd” now i store this string in char array and sort it which leads array to:- d,e,r,u

now i iterate from last character as its ascii value is max k times