Amazon Interview Question

Can't disclose but doing leetcode medium/hard helps