CoverMyMeds Interview Question

Hacker rank problem mostly. how well you optimise them