This CodeNewbie Challenge will help you learn some of the basic problems you might see on a white board in an interview. This challenge was based on some of the white board problems we’ve seen throughout interviews. The goal here is to familiarize yourself with the types of white board challenges you might face in an interview.
For this challenge we will begin with an array of strings:
["apple", "banana", "orange", "pear", "grape"]
In this challenge you will be manipulating this array and the strings within it.
In the first level you will start by reversing the order of the strings in the array. Your output should look as follows:
The second level starts with reversals in mind but instead of reversing the list you are now to reverse the strings themselves. Your output will look as follows:
Next you will take a user input string and reverse it. The input should look like:
Input a string to reverse:
With user input:
Input a string to reverse: antidisestablishmentarianism
And your output will look as follows:
The third level takes a user input and reverses it to determine if it is a palindrome or a word or phrase that is the same forward as backward. Your input screen will look as follows:
Enter a word or phrase:
If the user enters the word “aibohphobia” your output will be as follows:
aibohphobia is a palindrome
If the user enters the phrase “Are we not drawn onward to new era” your output will be as follows:
Are we not drawn onward to new era is a palindrome
If the user enters the word banana your output will be as follows:
banana is not a palindrome
You’ll need to remove the punctuation on phrases.
Going a step further with string manipulation try taking two strings and checking to see if they are anagrams (words or phrases with the same characters but in a different order). Your output should state the two strings and if they are or are not anagrams.
Torchwood and Doctor Who are anagrams
bicycle and acyclic are not anagrams
An easy way to do this is to check character count for each string. If they match they are anagrams.