Skills101
← All practice quizzes

Arrays & Hashing Quiz

8 questions12 minPass: 60%+10 XP on first pass

Hash sets, frequency maps, the Two Sum complement trick, prefix sums and Kadane's algorithm.

Log in to take the quiz

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

  1. Question 1

    Which data structure makes "have I seen this value before?" an O(1) average check?

  2. Question 2

    In the hash-map solution for Two Sum, what do we look up for each number x?

  3. Question 3

    Why do we store x in the map only AFTER checking for target − x in Two Sum?

  4. Question 4

    What does this code print?

    from collections import Counter
    c = Counter("banana")
    print(c["a"])
    
  5. Question 5

    What is the best time complexity to check whether two strings are anagrams?

  6. Question 6

    prefix = [0, 2, 5, 9, 14] for nums = [2, 3, 4, 5]. What is the sum of nums[1..3] (indices 1 to 3)?

  7. Question 7

    What does Kadane's algorithm return for [-2, 1, -3, 4, -1, 2, 1, -5, 4]?

  8. Question 8

    For "count subarrays with sum = k" where the array has NEGATIVE numbers, which approach works?