SpanIdea Interview Question

They asked me to find second largest element.