Amazon interview question

Loss functions, leetcode medium question.