You are viewing a single comment's thread. Return to all comments →
O(N) Javascript solution:
function alternatingCharacters(s) { let deletions = 0; for (let i = 0; i < s.length; i++) { if (s[i] === s[i + 1]) deletions++; } return deletions; }
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
O(N) Javascript solution: