Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many unordered pairs of distinct integers {a, b} from 1 to 12 are coprime to each other?
- A. 46
- B. 45
- C. 47
- D. 49
Correct answer: B. 45
Count all 66 pairs and subtract those sharing a prime factor, using inclusion-exclusion over the primes 2, 3, 5, 7, 11.
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 sum of i^3 mod 7 over i = 1 to 20?
- How many 1 bits does the binary representation of 45 contain?
- A robot on a circle of 8 positions (0 to 7) starts at 0 and jumps 3 positions forward each step, wrapping around. After how many steps…
- Trains arrive at times [900, 940, 950, 1100] and depart at times [910, 1200, 1120, 1130]. What is the minimum number of platforms needed…
- What is the most efficient general technique for the platform problem above (minimum platforms needed given arrival and departure times)?
- Binary search with mid = (lo + hi) // 2 on the sorted array 2 5 8 12 16 23 38 56 72 91 110 130 looks for the key 91. How many probes…