Logo

Coding preview

Reworking hierarchies to compile-time.

What this preview is

About this preview

Reworking hierarchies to compile-time. is a medium quant coding problem on design patterns in Cpp.

Unlock full access to getcracked

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

Refactoring runtime polymorphism to compile-time in C++

This medium-difficulty C++ design-patterns problem tests your ability to replace virtual dispatch with static polymorphism — a core technique in high-frequency trading systems where runtime overhead is unacceptable. The challenge is to preserve the same interface and behaviour while shifting polymorphic resolution from runtime to compile time.

The key insight is recognizing which design pattern eliminates virtual function calls while maintaining type-safe, polymorphic behaviour. Strong solutions will produce code that compiles to identical or faster machine code, passes all test cases without runtime indirection, and remains readable. You'll need to think carefully about how to express "this object can be one of several types, but we know which one at compile time" without pointers or virtual tables.

  • Static polymorphism vs. runtime polymorphism trade-offs
  • Template instantiation and type erasure
  • Zero-overhead abstractions in C++