Amazon interview question

Problems in DSA (one easy and one medium)