🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. Which data structure makes "have I seen this value before?" an O(1) average check?
  2. Q2. In the hash-map solution for Two Sum, what do we look up for each number x?
  3. Q3. Why do we store x in the map only AFTER checking for target − x in Two Sum?
  4. Q4. What does this code print? (code)
  5. Q5. What is the best time complexity to check whether two strings are anagrams?
  6. 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)?
  7. Q7. What does Kadane's algorithm return for [-2, 1, -3, 4, -1, 2, 1, -5, 4]?
  8. Q8. For "count subarrays with sum = k" where the array has NEGATIVE numbers, which approach works?