You are viewing a single comment's thread. Return to all comments →
js non recursive
function abbreviation(a, b) { const aLen = a.length; const bLen = b.length; let prevRow = Array(bLen); let curRow = Array(bLen); for (let aInd = 0; aInd < aLen; aInd++) { let prevLast = true; for (let bInd = 0; bInd < bLen; bInd++) { const c1 = a[aInd]; const c2 = b[bInd]; const isCap = c1 < 'a'; const last = prevRow[bInd]; [ curRow[bInd], prevLast ] = [ c1.toUpperCase() === c2 && prevLast || !isCap && last, last ]; } [prevRow, curRow] = [curRow, prevRow]; } return prevRow.pop() ? 'YES' : 'NO'; }
Seems like cookies are disabled on this browser, please enable them to open this website
Abbreviation
You are viewing a single comment's thread. Return to all comments →
js non recursive