WeInvest Interview Question

data structures and algorithms looping reasonings