Data Structures & AlgorithmsModerateCodeforces Div2 B · CRT
Problem: Find the smallest positive x satisfying x ≡ 2 (mod 3), x ≡ 3 (mod 5) and x ≡ 2 (mod 7).
- A. 128
- B. 58
- C. 2
- D. 23
Correct answer: D. 23
Checking 23: 23 mod 3 = 2, 23 mod 5 = 3, 23 mod 7 = 2. The solution is unique modulo 105, so 128 = 23 + 105 is valid but not the smallest.
More Coding Interview Problems questions
- Problem: Which pair (x, y) satisfies 240x + 46y = gcd(240, 46)?
- Problem: Cows must be placed in stalls at positions [1, 2, 4, 8, 9] so that the minimum distance between any two cows is as large as…
- Problem: Trains arrive at times [900, 940, 950, 1100, 1500, 1800] and depart at [910, 1200, 1120, 1130, 1900, 2000]. The two-pointer code…
- Problem: Return, for each index i, the product of all other elements (no division allowed). Print the list for a = [2, 3, 4, 5]. python a…
- Problem: How many distinct non-empty substrings does the string 'abab' contain? python s = 'abab' print(len({s[i:j] for i in range(len(s))…
- Problem: What is the maximum XOR of any two different elements of the array [3, 10, 5, 25, 2, 8]? python a = [3, 10, 5, 25, 2, 8]…