Prepping for the 2027 recruiting cycle? Use code 2027RC for 10% off, valid until July 31st! Oh, and check out our members-only recruitment services.

Logo

Lock Code Decryption

What this preview is

Lock Code Decryption is a hard quant coding problem on language knowledge in Cpp / Python, asked at Quant.

Difficulty
Hard
Topic
Language Knowledge
Discipline
Quant development
Languages
Cpp / Python

Hard coding problem: optimizing selection with coprimality constraints

This hard coding problem, asked by a tier-1 quant firm, combines discrete optimization with number-theoretic reasoning. You must find the maximum value of a selected number minus the cost of modifications needed to make that number coprime with all others in an array.

The core challenge is exploring which candidate values to select and, for each candidate, determining the minimum-cost modification set that allows it to be coprime with the rest. Since coprimality depends on greatest common divisors (GCD), you'll need to reason about which elements must be changed to eliminate shared factors with your chosen number. The solution requires balancing the value of the selected number against the cost of forcing coprimality—a classic trade-off in constrained optimization.

  • GCD computation and coprimality testing
  • Greedy and exhaustive search over candidate selections
  • Minimizing modification cost for a fixed candidate
  • Handling edge cases (single-element arrays, vacuous coprimality)

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.