We're a place where coders share, stay up-to-date and grow their careers.
I wrote the code (in Python) assuming that the missing letter is within the list, if not there would be 2 answers to it.
def missing_letter(input): for index in range(len(input) - 1): if ord(input[index + 1]) - ord(input[index]) != 1: return chr(ord(input[index]) + 1)
Here is my previous implementation, I wrote this to handle the scenario that the input list wasn't in an ascending order (I didn't read the question completely 🤣)
def missing_letter(input): arr = [input[0]] + [None] * len(input) for elem in input[1:]: if elem < arr[0]: offset = elem - arr[0] arr = arr[offset::] + arr[:offset] arr[0] = elem else: arr[ord(elem) - ord(arr[0])] = elem for index, elem in enumerate(arr): if elem is None: return chr(ord(arr[0]) + index)
I wrote the code (in Python) assuming that the missing letter is within the list, if not there would be 2 answers to it.
Here is my previous implementation, I wrote this to handle the scenario that the input list wasn't in an ascending order (I didn't read the question completely 🤣)