Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B
How many integers x in [1, 200] have x^2 mod 10 equal to 4?
- A. 41
- B. 42
- C. 44
- D. 40
Correct answer: D. 40
Squares end in 4 exactly when the last digit is 2 or 8, and each of these last digits occurs 20 times up to 200.
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
- Five people stand in a circle numbered 1 to 5. Starting from person 1, every third person is removed until one remains. Who survives?
- Gas stations are on a circular route: gas = [1, 2, 3, 4, 5] and the cost to reach the next station = [3, 4, 5, 1, 2]. Starting with an…
- Given a set of intervals, you want the fewest intervals to remove so the rest do not overlap. Which greedy strategy is correct?
- Which data structure answers range-minimum queries and point updates each in O(log n) time?
- From the numbers [1, 9, 4, 7, 3, 12, 8, 5], form as many DISJOINT pairs as possible where the two numbers in each pair differ by at most 2…
- A circular binary string is "1101001010". A swap exchanges any two characters. What is the minimum number of swaps needed so that all 1s…