Goldman Sachs Interview Question

2 Coding question of easy-medium level