Data Structures & AlgorithmsModerateICPC regional · TCS NQT
Problem: Compute (1³ + 2³ + … + 100³) modulo 1000.
- A. 50
- B. 775
- C. 500
- D. 350
Correct answer: C. 500
Σk³ = (n(n+1)/2)² = 5050² = 25502500, so the answer is 500. Not squaring gives 5050 mod 1000 = 50, applying n(n+1)/2 again gives 775, and Σk² = 338350 gives 350.
More Coding Interview Problems questions
- Problem: A trie stores the words "apple", "app", "apply", "ape", "banana". How many stored words start with the prefix "app" (including a…
- Problem: Subtraction game: from n stones a player may remove 1, 3 or 4 stones; the player who cannot move loses (no stones left on their…
- Problem: On the 4-cycle C4 (vertices 0-1-2-3-0), a walker starts at 0 and takes exactly 3 steps, each to an adjacent vertex. How many…
- Problem: The array [7, 3, 9, 1, 5] is processed by a selection that finds the position of the maximum, removes it, and repeats. The…
- Problem: How many 4-digit numbers (1000–9999) are palindromes (read the same forwards and backwards in decimal)?
- Problem: The string "abcabcabc" has how many distinct substrings of length 3?