Code Room
CodingHardcod-g407
Subject Number theoryLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given pairwise-coprime moduli and corresponding remainders, find the smallest non-negative x satisfying x = remainders[i] (mod moduli[i]) for all i, using the Chinese Remainder Theorem. Return a two-element list [x, M] where M is the product of all moduli and x is the unique solution in [0, M). Constraints: 1 to 10 congruences, each modulus 1 <= moduli[i] <= 1000, moduli are pairwise coprime, 0 <= remainders[i] < moduli[i].

Implement
crt(remainders: list[int], moduli: list[int]) → list[int]
Examples
in[[2,3,2],[3,5,7]]out[23,105]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.