Phantom AI interview question

Typical coding problem in C++