Sample solutions for WWC's Cracking the Interview questions
Sample solutions for my problem set for the WWC DFW Whiteboarding Workshop (Nov 13, 2019)
- Given a string, reverse it in any programming language you know and print the output
- Write pseudo code for solving Towers of Hanoi with 3 towers and 3 discs.
- Write a function that simulates rolling a die (1-6)
- Given a range of numbers 1 to N, find all the prime numbers.
- Numbers to ordinals; given an integer N, return a string that is that number in the form "Nth". Ex: 1=>1st, 5=>5th, 22=>22nd, etc.
- Find the missing numbers! Given an array of sequential numbers, find all the gaps in the sequence.
- Bubble sort - Traverse through a simple sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order
- Given a single input string, write a function that produces all possible anagrams of a string and outputs them as an array.
- Make me a randomized Bejeweled grid of 9x9 with 4 piece types where there are no "3 of a kind" in a row (diagonals don't count) and has at least one move available.
- Check if year is a leap year.
- Given a non-empty array of integers, return the k most frequent elements. Assume k is always valid, 1<=k<=number of unique elements