AppDynamics interview question

Standard algorithm leetcode medium