Interview Questions Flashcards
Things to consider in whiteboard interviews while trying to understand the problem
if the input is a string or an array, could it be empty? If so, what should the output be?
if the input is a number, could it be negative or zero? If so, what should the output be?
if the input is an array, is it sorted?
if the input is a number, could it be an integer or a decimal?
if the input is an array, could it contain duplicate elements?
Example Pseudo Code
Define a function named sumAll that takes an array of numbers and returns their sum.
declare variable to hold the sum, initialized at 0
use a loop to iterate through the array from beginning to end
for each number in the array:
add the number to the current sum
assign the result of the addition back to the sum
after the loop completes, return the final value of sum
Steps to take when you first get the problem from interviewer
Write down the prompt. Understand the problem. Write pseudo-code for a solution. Translate the pseudo-code to actual code. Trace the code with example inputs.
Common types of technical questions asked
variables
conditionals
loops
primitive data (booleans, numbers, strings)
collections (objects, arrays, and maybe a couple of other data structures)
functions / methods