Find the largest and second largest element in an array
Given an array which includes integer elements. Our goal is to find the largest and 2nd largest element which are present in given array. For example.
Example A
arr1[] = {10 , 3 , 23 , 86 , 8 , 9 , 44 , 5 , 7}
⇧ ⇧

First Largest : 86
Second Largest : 44
Example B
arr2[] = {10 , 3 , 11 , 16 , 8 , 16 , 5 , 9 , 7}
⇧ ⇧

First Largest : 16
Second Largest : 16
Example C
arr3[] = { 10 }

None
(Because less than 2 element)
Here given code implementation process.

1) Find the largest and second largest element of array in java
2) Find the largest and second largest element of array in c++
3) Find the largest and second largest element of array in c#
4) Find the largest and second largest element of array in c
5) Find the largest and second largest element of array in vb.net
6) Find the largest and second largest element in an array in node js
7) Find the largest and second largest element of array in scala
8) Find the largest and second largest element of array in swift
9) Find the largest and second largest element of array in kotlin
10) Find the largest and second largest element in an list in python
11) Find the largest and second largest element in an array in ruby
12) Find the largest and second largest element in an array in golang
13) Find the largest and second largest element of array in typescript
14) Find the largest and second largest element of array in php
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment