Amazon interview question

Leetcode 2 medium question based on sliding window and Hash map