Pregunta de entrevista de Comcast

Asked to write code for algorithm/use inbuilt function and time complexity of it