@icure/cardinal-prescription-be-react
Version:
This is a Belgian-specific React application for healthcare professionals to manage electronic prescriptions with SAM. Created by iCure.
19 lines (14 loc) • 484 B
text/typescript
export const findCommonSequence = (str1: string, str2: string) => {
let commonSequence = ''
// Determine the maximum possible overlap
const maxOverlap = Math.min(str1.length, str2.length)
for (let i = 1; i <= maxOverlap; i++) {
// Get the suffix of str1 and prefix of str2
const suffix = str1.slice(-i)
const prefix = str2.slice(0, i)
if (suffix === prefix) {
commonSequence = suffix // Update the common sequence
}
}
return commonSequence
}