Skills101
← DSA Interview Mock Test Series

Mock 1 — Arrays, Strings & Hashing

10 questions15 minPass: 60%+20 XP on first passFree sample test

10 questions · 15 minutes · free sample of the DSA Interview Mock Test Series.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    nums = [3, 1, 4, 1, 5]
    seen = set()
    dup = None
    for x in nums:
        if x in seen:
            dup = x
            break
        seen.add(x)
    print(dup)
    
  2. Question 2

    What is the time complexity of the code above for n elements?

  3. Question 3Select all that apply

    Group Anagrams: which key groups "eat", "tea" and "ate" together? (select all that apply)

  4. Question 4

    What is the maximum subarray sum of [5, -9, 6, -2, 3]?

  5. Question 5

    What does this Java snippet print?

    String a = new String("hi");
    String b = new String("hi");
    System.out.println(a == b);
    
  6. Question 6

    Product of Array Except Self for [1, 2, 3, 4] returns…

  7. Question 7

    How many subarrays of [1, 1, 1] have sum 2?

  8. Question 8

    Which approach finds the majority element (appears > n/2 times) in O(n) time and O(1) space?

  9. Question 9

    What is the longest consecutive sequence length in [100, 4, 200, 1, 3, 2]?

  10. Question 10

    Which is the fastest correct way to check if two lowercase strings are anagrams?