Count ordered fragment pairs forming a password | Capital One Interview Question