Analyze attention complexity and improvements | Amazon Interview Question