Find the Second Largest Number in an Array

Let’s discuss a problem to find the second largest number in an array.

Given an unsorted array of integers, write a code to find the second largest number in an array.

For example –

Input – arr[] = { 4, 1, 5, 2, 8, 0, 3, 55}

Output – 8

The second max element in this array is 8.

Before checking the solution, let’s think for a moment, how do you approach this problem?  There are multiple ways to solve this problem. Which approach you prefer and why? At the end of this tutorial, I have shared the link to the video tutorial.

In this tutorial, I am going to cover following topics –

  • How to find the second largest number in an array using sorting.
  • C program to find the second largest number in an array.
  • C++ program to find the second largest number in an array.

Singleton Design Pattern in PHP

In this tutorial, I am going to discuss what is singleton design pattern, Why and when to use singleton design pattern in php.

What is Singleton Design Pattern?

In Singleton Design Pattern, we ensure a class has only one and only one instance and that instance can be accessed globally. The Singleton design pattern restricts the instantiation of a class to one object.

How to Create Singleton Class in PHP