Data Structures & AlgorithmsModerateGATE CS · ICPC regional
How many primes p with 2 <= p <= 30 satisfy p ≡ 1 (mod 4)?
- A. 5
- B. 6
- C. 4
- D. 8
Correct answer: C. 4
The primes up to 30 that are 1 modulo 4 are 5, 13, 17 and 29.
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
- How many integers x in [1, 100] satisfy x ≡ 3 (mod 4) and x ≡ 7 (mod 10)?
- What is 2^100 mod 9?
- A 12-hour clock shows 1:30 p.m. Ignoring seconds, what hour (1 to 12) is shown 500 minutes later?
- Starting at x = 1, repeatedly apply x -> 3x mod 11. How many steps are needed to return to 1?
- Starting from n = 100, repeat: if n is divisible by 3, divide it by 3; otherwise subtract 1. How many steps are needed to reach 1?
- Which structure finds the k-th largest element of a data stream after each insertion with O(log k) time per element and O(k) space?