Super Reduced String

ZeeshanAli-0704 - Aug 23 '22 - - Dev Community

Just try working with sub-string & index

function superReducedString(s) {
  let left = 0;
  let right = 1;
  let subStr = s;
  while (right <= subStr.length)
    if (subStr[left] === subStr[right]) {
      subStr = subStr.substring(0, left) + subStr.substring(right + 1);
      left = 0;
      right = 1;
      i = 0;
    } else {
      left++;
      right++;
    }

  return subStr;
}

console.log(
  "Answere here ====>",
  superReducedString(
    "kagoyzkgfjnyvjewazalxngpdcfahneqoqgiyjgpzobhaghmgzmnwcmeykqzgajlmuerhhsanpdtmrzibswswzjjbjqytgfewiuu"
  )
);

// kagoyzkgfjnyvjewazalxngpdcfahneqoqgiyjgpzobhaghmgzmnwcmeykqzgajlmuersanpdtmrzibswswzbjqytgfewi-> output


Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player