All 84 questions

  1. Write a program to generate the Fibonacci series.

    Asked in 8 of 374 interviews · last asked Oct 14 · Write code · Junior

    Show answer

    I generate the first n Fibonacci numbers, starting with 0 and 1. Each later number is the sum of the previous two. This Python solution uses a loop and returns the numbers in a list.

    • Update both values together so the calculation uses their old values.
    • For n = 0, return an empty list; reject negative n.
    • Time is O(n), and the returned list uses O(n) space, assuming constant-cost integer arithmetic.
    Python
    def fibonacci(n):
        if n < 0:
            raise ValueError("n must be non-negative")
        result = []
        a, b = 0, 1
        for _ in range(n):
            result.append(a)
            a, b = b, a + b
        return result
    print(fibonacci(7))  # [0, 1, 1, 2, 3, 5, 8]

    What the interviewer checks: The interviewer checks whether you can use a loop, update values correctly, and handle small inputs.

    Common mistake (in 5 of 5 reviewed answers): Many answers forget that each new term must be computed as the sum of the previous two.

    Other ways it was asked
    • “Write a Python program to display the Fibonacci series.”
    • “Write a Python program for the Fibonacci series.”
    • “Can you write Python code to generate the Fibonacci sequence?”
  2. What is the difference between mutable and immutable data types, and where would you use them?

    Asked in 4 of 374 interviews · last asked Oct 22 · Concept · Junior

    Show answer

    Mutable objects can change after they are created. Immutable objects cannot; a different value requires a different object. Use mutable types for data you update often, such as a growing list. Use immutable types for values that should stay fixed or be shared without changes, such as strings in Python.

    • Changing a mutable object can affect every variable that refers to it.
    • Reassigning a variable is not the same as changing its object.
    • In Python, lists are mutable and strings are immutable.
    • Immutable containers can still hold mutable objects; a Python tuple can contain a list.
    Python
    items = [1, 2]
    shared = items
    items.append(3)
    print(shared)  # [1, 2, 3]: the same list changed
    
    name = "Sam"
    original = name
    name = name + "!"
    print(original)  # Sam: the original string did not change

    What the interviewer checks: The interviewer checks whether you understand object changes, shared references, and when to use each type.

    Other ways it was asked
    • “Give one example of a mutable data type and one example of an immutable data type.”
    • “Give an example of a mutable and an immutable data type, and explain how you can tell the difference.”
    • “What is the basic difference between a mutable data type and an immutable data type?”
  3. Write a Python program to check whether a number is prime.

    Asked in 3 of 374 interviews · last asked Oct 17 · Write code · Junior

    Show answer

    Check whether the integer has a divisor between 2 and its square root. Numbers below 2 are not prime. If no divisor is found, the number is prime.

    • Negative numbers, 0, and 1 are not prime.
    • 2 is prime; all other even numbers are not.
    • Check through the square root, including it, to catch perfect squares.
    • Trial division takes O(√n) time and O(1) extra space.
    Python
    from math import isqrt
    def is_prime(n):
        if n < 2:
            return False
        if n % 2 == 0: return n == 2
        for divisor in range(3, isqrt(n) + 1, 2):
            if n % divisor == 0:
                return False
        return True
    print(is_prime(int(input())))

    What the interviewer checks: The interviewer is checking correct edge cases and whether you avoid testing divisors beyond the square root.

    Other ways it was asked
    • “Write Python code to determine whether a number is prime.”
  4. Write a function that prints “even” if a number x is even, or “odd” otherwise.

    Asked in 2 of 374 interviews · last asked Aug 21 · Write code · Junior

    Other ways it was asked
    • “Write a program that prints "even" if a number x is even, otherwise prints "odd".”
  5. Write a program to find and print prime numbers in a given range.

    Asked in 2 of 374 interviews · last asked Sep 28 · Write code · Junior

    Other ways it was asked
    • “Can you write a Java program for finding prime numbers?”
    • “What approach would you use to find and print all prime numbers between 1 and 51?”
    • “Can you walk me through a dry run of an algorithm that prints all prime numbers between 1 and 51?”
  6. What is an algorithm?

    Asked in 2 of 374 interviews · last asked Apr 4 · Concept · Junior

  7. Write a program to find a factorial.

    Asked in 2 of 374 interviews · last asked Sep 18 · Write code · Junior

    Other ways it was asked
    • “Write a basic program to find the factorial of a number.”
  8. What is a data structure?

    Asked in 2 of 374 interviews · last asked Sep 7 · Concept · Junior

  9. What is the Fibonacci series?

    Asked in 2 of 374 interviews · last asked Sep 13 · Concept · Junior

    Other ways it was asked
    • “Explain the Fibonacci sequence.”
  10. Where should we use a for loop?

    Asked in 2 of 374 interviews · last asked Aug 12 · Concept · Junior

    Other ways it was asked
    • “What is a for loop?”
  11. What is Big-O notation?

    Asked in 2 of 374 interviews · last asked Aug 20 · Concept · Junior

    Other ways it was asked
    • “What's the purpose of Big O notation, and what does it describe about an algorithm?”
  12. How would you estimate the runtime complexity of an algorithm?

    Asked once · last asked Jul 22 · Write code · Mid-level

  13. Are array elements homogeneous, meaning that every element must have the same type, such as integers or characters?

    Asked once · last asked Mar 31 · Concept · Junior

  14. How do you reason about time and space complexity in JavaScript, and how does that influence your choice of data structures when writing code?

    Asked once · last asked May 15 · Concept · Senior

  15. Implement a two-player game of rock, paper, scissors: take each player's move as input and report whether there is a winner and who won.

    Asked once · last asked Jun 9 · Write code · Junior

  16. Starting with x and y set to zero, how would you process a sequence of movement commands to return the final coordinates, and what data structure would you use to evaluate the commands efficiently?

    Asked once · last asked Nov 17 · Write code · Junior

  17. Write a Java program to find prime numbers in a matrix.

    Asked once · last asked Jul 23 · Write code · Junior

  18. How do arrays, slices, and maps work internally?

    Asked once · last asked Jul 31 · Concept · Mid-level

  19. How would you assess a prime-checking approach that checks divisibility by 2 and 3, then tests potential factors starting at 5 in steps of 6 up to the square root?

    Asked once · last asked Sep 3 · Write code · Mid-level

    Other ways it was asked
    • “How would you assess an approach that checks divisibility by 2 and 3, then tests factors from 5 in steps of 6 up to the square root?”
    • “How would you check whether a number is prime by testing divisibility by 2 and 3, then factors from 5 in steps of 6 up to its square root?”
  20. Can you trace how the optimized prime-checking loop works for the number 29?

    Asked once · last asked Sep 3 · Write code · Junior

  21. How should a prime-checking function handle a five-digit input that ends in 6?

    Asked once · last asked Sep 3 · Write code · Junior

  22. Can a 2,000-digit value of b fit in a standard integer type?

    Asked once · last asked Sep 7 · Concept · Junior

  23. What is the time complexity of the naive DFT?

    Asked once · last asked Sep 29 · Concept · Junior

  24. What does N represent in the time complexity of the naive DFT, and how would you measure a reported 7,000-fold speedup?

    Asked once · last asked Sep 29 · Scenario · Mid-level

  25. How would you write code to swap two numbers using a temporary variable?

    Asked once · last asked Oct 12 · Write code · Junior

  26. Write a function to find the sum of odd numbers in a Fibonacci series.

    Asked once · last asked Oct 14 · Write code · Junior

  27. How do you calculate the sum of odd numbers or count how many odd numbers are present in a set of prime numbers?

    Asked once · last asked Oct 14 · Write code · Junior

  28. Write code to generate the Fibonacci series of n terms.

    Asked once · last asked Oct 21 · Write code · Junior

  29. Can an array store both integers and floating-point values?

    Asked once · last asked Aug 27 · Concept · Junior

    Other ways it was asked
    • “How can an array store both integers and floating-point values?”
  30. What is the time complexity of searching for an element in a list?

    Asked once · last asked May 25 · Concept · Junior

    Other ways it was asked
    • “Why does searching for an element in a list have that time complexity?”
  31. What is the result of 20 % 5?

    Asked once · last asked Sep 25 · Write code · Junior

    Other ways it was asked
    • “What is the result of the expression 20 % 5 + 20 / 5?”
  32. What is the core difference between a subsequence and a sequence?

    Asked once · last asked Oct 11 · Concept · Junior

  33. How do you swap the values of two variables without using a third variable?

    Asked once · last asked Oct 18 · Write code · Junior

    Other ways it was asked
    • “Can you write the logic for swapping the values of two variables without using a third variable?”
  34. Why do we use data structures?

    Asked once · last asked Mar 16 · Concept · Junior

  35. Why are data structures important for writing effective code?

    Asked once · last asked Mar 16 · Concept · Junior

  36. Can you define the scope of a variable?

    Asked once · last asked Mar 24 · Concept · Junior

  37. What is type coercion?

    Asked once · last asked Mar 27 · Concept · Junior

    Other ways it was asked
    • “What is coercion, the automatic conversion of a value from one data type to another?”
  38. How would you check whether a number is prime?

    Asked once · last asked Apr 8 · Write code · Junior

  39. Is the Java Stream API related to time and space complexity?

    Asked once · last asked Apr 17 · Concept · Mid-level

  40. How would you add a method that adds three numbers?

    Asked once · last asked Apr 20 · Write code · Junior

  41. How do you convert the decimal number 47 to binary, and what is the result?

    Asked once · last asked May 7 · Concept · Junior

  42. What method do you use to convert a number to binary, and what basic operation do you perform?

    Asked once · last asked May 7 · Concept · Junior

  43. When converting a number to binary by division, what number do you divide by?

    Asked once · last asked May 7 · Concept · Junior

  44. What is computational complexity, and how can it help assess an algorithm's runtime?

    Asked once · last asked May 19 · Concept · Junior

  45. What data types and data structures do you know in Python?

    Asked once · last asked May 25 · Concept · Junior

  46. After clarifying a problem's inputs, how would you proceed with solving it?

    Asked once · last asked Jun 17 · Scenario

  47. Given two numbers, calculate their sum, store it in another variable, and print the result.

    Asked once · last asked Jun 29 · Write code · Junior

  48. Can you explain the palindrome concept and the Fibonacci series in Python?

    Asked once · last asked Jul 16 · Concept · Junior

  49. How do you choose a data structure for a problem, and can you illustrate your choice with an example?

    Asked once · last asked Jul 24 · Concept

  50. How can you improve the time complexity of an algorithm?

    Asked once · last asked Jul 25 · Concept · Mid-level

  51. How can you control the structure and alignment of precisely formatted console output in a program?

    Asked once · last asked Aug 10 · Write code · Junior

  52. What are iterators?

    Asked once · last asked Dec 4 · Concept · Junior

  53. What is the difference between homogeneous and heterogeneous data elements?

    Asked once · last asked Aug 14 · Concept · Junior

  54. If a loop runs n times and inside it another loop runs n times, what's the time complexity?

    Asked once · last asked Aug 14 · Concept · Junior

  55. What are the common asymptotic notations, and what does each describe?

    Asked once · last asked Aug 20 · Concept · Junior

  56. What does Theta signify, and how is it different from Big-O?

    Asked once · last asked Aug 20 · Concept · Junior

  57. What is a Boolean value?

    Asked once · last asked Aug 21 · Concept · Junior

    Other ways it was asked
    • “What is a Boolean number?”
  58. Do you know what break and continue do?

    Asked once · last asked Aug 24 · Concept · Junior

  59. Swap two variables, a = 10 and b = 20, without using a third variable.

    Asked once · last asked Aug 24 · Write code · Junior

  60. What are the first 10 numbers in the Fibonacci sequence?

    Asked once · last asked Sep 1 · Write code · Junior

  61. Write a function or pseudocode to generate the first 10 numbers in the Fibonacci sequence.

    Asked once · last asked Sep 1 · Write code · Junior

  62. How would you stop iteration over an unbounded Fibonacci sequence after generating only the first 10 values?

    Asked once · last asked Sep 1 · Write code · Junior

  63. Can you write a short program in any language to determine whether a number is prime?

    Asked once · last asked Sep 2 · Write code · Junior

  64. Write a program to find the factors of two given numbers.

    Asked once · last asked Sep 3 · Write code · Junior

  65. Can you write Python code to calculate the factorial of a number?

    Asked once · last asked Sep 8 · Write code · Junior

  66. What do you mean by modulus?

    Asked once · last asked Sep 9 · Concept · Junior

    Other ways it was asked
    • “When do you use the modulus function?”
  67. Write a program that determines whether a number supplied as a string is an Armstrong number.

    Asked once · last asked Sep 19 · Write code · Junior

    Other ways it was asked
    • “Write a program that determines whether a given number is an Armstrong number.”
  68. Write code to determine whether a given number is even or odd.

    Asked once · last asked Sep 19 · Write code · Junior

  69. What types of operators are available?

    Asked once · last asked Sep 25 · Concept · Junior

  70. What is the purpose of the remainder (modulus) operator?

    Asked once · last asked Sep 25 · Concept · Junior

  71. What result do you get when dividing 20 by 6 using integer operands?

    Asked once · last asked Sep 25 · Write code · Junior

  72. If multiplication and division are both in the expression, which operation is performed first?

    Asked once · last asked Sep 25 · Concept · Junior

  73. When multiplication and division have the same precedence, how is the order of evaluation determined?

    Asked once · last asked Sep 25 · Concept · Junior

  74. What is type conversion, and when is it used?

    Asked once · last asked Sep 25 · Concept · Junior

  75. What are data structures and algorithms (DSA)?

    Asked once · last asked Sep 30 · Concept · Junior

  76. What is the difference between an algorithm and a data structure?

    Asked once · last asked Oct 5 · Concept · Junior

  77. In Elixir, what is the opposite of `if` that runs when a condition is false?

    Asked once · last asked Oct 13 · Concept · Junior

  78. In Elixir, can tuples contain only atoms, or can they contain values of any data type?

    Asked once · last asked Oct 13 · Concept · Junior

  79. Can pattern matching be used to assign values from a tuple in Elixir?

    Asked once · last asked Oct 13 · Concept · Junior

  80. How would you validate that d is an integer between 1 and 6 and, if it is, access the tuple?

    Asked once · last asked Oct 13 · Write code · Junior

  81. Can you write a function to find the factorial of a number?

    Asked once · last asked Oct 18 · Write code · Junior

  82. What are the time and space complexities of converting an integer to a Roman numeral?

    Asked once · last asked Oct 19 · Concept · Junior

  83. How do you convert a binary number to decimal?

    Asked once · last asked Oct 21 · Concept · Junior

  84. What is coding used for?

    Asked once · last asked Jan 14 · Concept · Junior

More Data Structures and Algorithms interview questions

How this list is made

Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.

Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.

The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Data Structures and Algorithms interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.

374 interviews, 269 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.