3
* @param {string} pattern6
var maximumSubsequenceCount = function (text, pattern) {7
const arrText = text.split("");8
const lengthP0 = arrText.filter((x) => x === pattern[0]).length;9
const lengthP1 = arrText.filter((x) => x === pattern[1]).length;10
const [c1, c2, lengthmax] =12
? [...pattern, lengthP1]13
: [pattern[1], pattern[0], lengthP0];14
let newText = lengthP0 <= lengthP1 ? [c1, ...arrText] : [...arrText, c1];15
newText = lengthP0 <= lengthP1 ? newText : newText.reverse();19
let countmax = lengthmax;20
while (i < newText.length) {21
if (newText[i] === c1) {24
if (newText[i] === c2) {