Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
What is the sum of a_n = n mod 7 for n from 1 to 20 inclusive?
- A. 64
- B. 63
- C. 62
- D. 30
Correct answer: B. 63
Blocks n = 1 to 6, 8 to 13 and 15 to 20 each contribute 1 + 2 + ... + 6 = 21, and the multiples of 7 contribute 0, so the total is 63.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- From [1, 2, 2, 3, 5, 6, 6], what is the maximum number of disjoint pairs where the two values differ by at most 1?
- How many integers from 1 to 64 inclusive have a binary representation (without leading zeros) that reads the same forwards and backwards?
- What is the minimum number of characters that must be inserted anywhere in "abcb" to make it a palindrome?
- How many windows of size 4 in [1, 2, 1, 3, 4, 2, 5, 6] contain four pairwise distinct values?
- What is the smallest positive integer n such that n! ends in exactly 10 trailing zeros?
- Items [1, 1, 1, 1, 2, 2, 3] must be placed into stacks of capacity 3 such that each stack holds only identical items. What is the minimum…