Fiserv Interview Question

The coding part was a little tough.