← All topics
Arrays & Hashing Quiz: questions with answers
8 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. Which data structure makes "have I seen this value before?" an O(1) average check?
- Q2. In the hash-map solution for Two Sum, what do we look up for each number x?
- Q3. Why do we store x in the map only AFTER checking for target − x in Two Sum?
- Q4. What does this code print? (code)
- Q5. What is the best time complexity to check whether two strings are anagrams?
- Q6. prefix = [0, 2, 5, 9, 14] for nums = [2, 3, 4, 5]. What is the sum of nums[1..3] (indices 1 to 3)?
- Q7. What does Kadane's algorithm return for [-2, 1, -3, 4, -1, 2, 1, -5, 4]?
- Q8. For "count subarrays with sum = k" where the array has NEGATIVE numbers, which approach works?