Implement string/matrix simulations and counting pairs | Capital One Interview Question