We can create two sets SSS_SSS and STS_TST by generating kkk-shingles for the strings SSS and TTT, respectively. Then we can calculate the intersection SIS_ISI and union SUS_USU between the two sets. Finally, we need to divide the length of SIS_ISI by the length of SUS_USU.
Complexity: O(∣S∣×∣T∣)O(|S|\times |T|)O(∣S∣×∣T∣)