The Sock Merchant problem is an algorithm challenge that tests our ability to work with arrays, counting, and basic data…