Maximize protected population and bitwise AND | Amazon Interview Question