Bloomberg Interview Question

Leetcode medium question, one is invalid transactions, forgot the other one