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)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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.
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 🤣)