missingLetters

Medium · String Manipulations · 3 test cases

Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined.

Examples

missingLetters('abce') → 'd'
missingLetters('abcdefghjklmno') → 'i'

Starter code

function missingLetters(str) {

}

Complexity of the optimal solution

Time O(n), space O(1). The function iterates through the string once, performing a constant time character code comparison at each step. This results in linear time complexity. Space usage is constant.

Solve missingLetters in the browser