> For the complete documentation index, see [llms.txt](https://tanias-workspace.gitbook.io/tanias-little-corner/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tanias-workspace.gitbook.io/tanias-little-corner/problems/second-largest.md).

# Second Largest

<figure><img src="/files/ACZcQZuOpZaEpVXUrr3a" alt=""><figcaption></figcaption></figure>

## Approach

* Sorts the array in ascending order
* Iterates from the end to find the first element that's smaller than the last element
* Returns this element as the second largest

<figure><img src="/files/3JosfoE74jaEDlxrOYLv" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/JznSBgElwFtGCdEoMMnm" alt=""><figcaption></figcaption></figure>
