What you described is known as Levenshtein distance.
There is library called Apache commons-text that you can use to do it for you.
int ops = new LevenshteinDistance().apply(string1, string2)
Here is source code
3
solved Calculate number of Updation, Insertion and Deletion on a One String to reach Another String [closed]