Reddit interview question

A leetcode like transaction problem.