Deutsche Bank Interview Question

case was challenging