Skip to content

Instantly share code, notes, and snippets.

@wafisher
Last active April 15, 2017 01:27
Show Gist options
  • Save wafisher/7ab93c69c702959f40015497ac0753af to your computer and use it in GitHub Desktop.
Save wafisher/7ab93c69c702959f40015497ac0753af to your computer and use it in GitHub Desktop.

Missing Letters

The sentence "A quick brown fox jumps over the lazy dog" contains every single letter in the alphabet. Such sentences are called pangrams.

You are to write a method getMissingLetters(), which takes as input a String containing a sentence and returns all the letters not present at all in the sentence (i.e. the letters that prevent it from being a pangram).

You should ignore the case of the letters in sentence, and your return should be all lowercase letters, in alphabetical order. You should also ignore all non-alphabet characters as well as all non-US-ASCII characters. Imagine that the method you write will be called many thousands of times in rapid succession on strings with length ranging from 0 to 50.

Accordingly, you should try to write code that runs as quickly as possible. Also, imagine the case when the input string is quite large (e.g., tens of megabytes). See if you can develop an algorithm that handles this case efficiently while still running very quickly on smaller inputs.

Examples

(Note that in the examples below, the double quotes should not be considered part of the input or output strings.)

Input Text Output
"A quick brown fox jumps over the lazy dog" ""
"A slow yellow fox crawls under the proactive dog" "bjkmqz"
"Lions, and tigers, and bears, oh my!" "cfjkpquvwxz"
"" "abcdefghijklmnopqrstuvwxyz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment