Data Structures & AlgorithmsHardGATE CS · ICPC regional
How many integers n in [1, 60] satisfy n^2 - n divisible by 6?
- A. 41
- B. 42
- C. 44
- D. 40
Correct answer: D. 40
n^2 - n = n(n-1) is always even, so the test is divisibility by 3; n(n-1) is divisible by 3 exactly when n is 0 or 1 modulo 3.
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
- What is the length of the longest contiguous subarray of [4, 3, 2, 6, 1, 5] whose sum is at most 10?
- How many times does the pattern aab occur in the string aabaabaab, counting overlapping matches?
- How many pairs (a, b) with 1 <= a <= b <= 12 satisfy lcm(a, b) > 36?
- Treat [4, -1, 5, -6, 3] as circular. Over all contiguous circular windows of length 1 to 5, what is the maximum window sum?
- How many integers from 1 to 1000 inclusive have a decimal digit sum equal to 10?
- What is the length of the longest contiguous subarray of [2, 2, 1, 3, 1, 1, 2] whose sum is divisible by 4?