Super Reduced String

  • + 0 comments

    just adding another approach for reference

    let array =[] for (const ch of s) { if (array.length && array[array.length-1]==ch){ array.pop(); } else { array.push(ch) } } return array.join('') || "Empty String"