Eight (8) Beginner Whiteboard Programming Questions

Alright, let’s talk about whiteboarding. Look, I know it might seem scary at first – standing up there, marker in hand, trying to solve problems while someone watches. But here’s the thing: whiteboarding isn’t about being perfect. It’s about showing how you think through problems.

These 8 questions are your training wheels. They’re designed to help you practice the fundamental skills you’ll need when you’re standing in front of that whiteboard in an interview or code review. Each one covers a different concept, from basic string manipulation to more complex problem-solving patterns.

Don’t worry about memorizing the solutions – that’s not the point. The real skill is learning to break down problems, ask the right questions, and work through your logic step by step. I’ve seen students who can solve these problems in their sleep but freeze up during interviews because they never practiced the process of whiteboarding.

So grab a marker (or just use your computer screen), pick a problem, and talk through it out loud. Yes, out loud – even if you’re alone. Trust me, this is huge for building confidence.

General Whiteboard Tips

  1. Start with clarifying questions - Ask about edge cases, input constraints
  2. Work through an example - Trace through the logic with sample input
  3. Write the function signature first - Define inputs and outputs clearly
  4. Think out loud - Explain your reasoning as you code
  5. Test your solution - Walk through your code with the example
  6. Discuss time/space complexity - Big O notation when relevant
  7. Consider edge cases - Empty inputs, negative numbers, etc.
  8. Keep code clean - Use meaningful variable names, proper indentation

Question 1: Reverse a String

Problem: Write a function that takes a string as input and returns the string reversed.

Example: Input: “hello” → Output: “olleh”

Solution:

1def reverse_string(s):
2    result = ""
3    for i in range(len(s) - 1, -1, -1):
4        result += s[i]
5    return result
6
7# Alternative solution using slicing
8def reverse_string_v2(s):
9    return s[::-1]

Whiteboard Tips: Start with the function signature, walk through an example, then implement step by step.


Question 2: Find the Maximum Number in an Array

Problem: Given an array of integers, find and return the largest number.

Example: Input: [3, 7, 2, 9, 1] → Output: 9

Solution:

1def find_max(arr):
2    if not arr:  # Handle empty array
3        return None
4    
5    max_num = arr[0]
6    for i in range(1, len(arr)):
7        if arr[i] > max_num:
8            max_num = arr[i]
9    return max_num

Whiteboard Tips: Always consider edge cases like empty arrays. Trace through with the example.


Question 3: Count Vowels in a String

Problem: Write a function that counts the number of vowels (a, e, i, o, u) in a given string.

Example: Input: “programming” → Output: 3

Solution:

1def count_vowels(s):
2    vowels = "aeiouAEIOU"
3    count = 0
4    for char in s:
5        if char in vowels:
6            count += 1
7    return count

Whiteboard Tips: Define what counts as a vowel upfront. Consider case sensitivity.


Question 4: Check if a Number is Even or Odd

Problem: Write a function that determines if a given integer is even or odd.

Example: Input: 4 → Output: “even”, Input: 7 → Output: “odd”

Solution:

1def even_or_odd(num):
2    if num % 2 == 0:
3        return "even"
4    else:
5        return "odd"

Whiteboard Tips: This is simple but good for demonstrating basic conditional logic and modulo operator.


Question 5: Sum of Array Elements

Problem: Calculate the sum of all numbers in an array.

Example: Input: [1, 2, 3, 4, 5] → Output: 15

Solution:

1def array_sum(arr):
2    total = 0
3    for num in arr:
4        total += num
5    return total
6
7# Alternative using built-in function
8def array_sum_v2(arr):
9    return sum(arr)

Whiteboard Tips: Show both manual loop and built-in function approaches.


Question 6: Find Duplicate Numbers

Problem: Given an array of integers, find and return the first number that appears more than once.

Example: Input: [1, 2, 3, 2, 4] → Output: 2

Solution:

1def find_first_duplicate(arr):
2    seen = set()
3    for num in arr:
4        if num in seen:
5            return num
6        seen.add(num)
7    return None  # No duplicates found

Whiteboard Tips: Explain the use of a set for O(1) lookup time. Discuss time/space complexity.


Question 7: Factorial Calculation

Problem: Write a function to calculate the factorial of a given positive integer.

Example: Input: 5 → Output: 120 (because 5! = 5 × 4 × 3 × 2 × 1)

Solution:

 1# Iterative approach
 2def factorial_iterative(n):
 3    if n < 0:
 4        return None  # Undefined for negative numbers
 5    if n == 0 or n == 1:
 6        return 1
 7    
 8    result = 1
 9    for i in range(2, n + 1):
10        result *= i
11    return result
12
13# Recursive approach
14def factorial_recursive(n):
15    if n < 0:
16        return None
17    if n == 0 or n == 1:
18        return 1
19    return n * factorial_recursive(n - 1)

Whiteboard Tips: Great for showing both iterative and recursive thinking. Discuss base cases.


Question 8: Check if String is a Palindrome

Problem: Determine if a given string reads the same forwards and backwards (ignoring spaces and case).

Example: Input: “racecar” → Output: True, Input: “hello” → Output: False

Solution:

 1def is_palindrome(s):
 2    # Clean the string: remove spaces and convert to lowercase
 3    cleaned = s.replace(" ", "").lower()
 4    
 5    # Compare with its reverse
 6    return cleaned == cleaned[::-1]
 7
 8# Alternative two-pointer approach
 9def is_palindrome_v2(s):
10    cleaned = s.replace(" ", "").lower()
11    left = 0
12    right = len(cleaned) - 1
13    
14    while left < right:
15        if cleaned[left] != cleaned[right]:
16            return False
17        left += 1
18        right -= 1
19    
20    return True

Whiteboard Tips: Good for demonstrating string manipulation and two-pointer technique.


General Whiteboard Tips

  1. Start with clarifying questions - Ask about edge cases, input constraints
  2. Work through an example - Trace through the logic with sample input
  3. Write the function signature first - Define inputs and outputs clearly
  4. Think out loud - Explain your reasoning as you code
  5. Test your solution - Walk through your code with the example
  6. Discuss time/space complexity - Big O notation when relevant
  7. Consider edge cases - Empty inputs, negative numbers, etc.
  8. Keep code clean - Use meaningful variable names, proper indentation