Bloomberg interview question

how to solve the valid transaction algorithm problem