How To Find Largest And Second Largest Element Without Sorting Array Logic

preview_player
Показать описание
How To Find Largest And Second Largest Element Without Sorting Array Logic. logic can be applied to many programming languages like C,C++, Java
Рекомендации по теме
Комментарии
Автор

the second if statement is not neccesary because to print second largest number just print max2 and to print the largest print max1, Thanks a lot for the logic👌👌👌👌👌👌

RandomStuff
Автор

Very Good.It works even for negative also, you just need to initialize as largest negative numbers. It will work in all, all negative, all positive, mix data as per my testing till now.
int
int

nitinsoni
Автор

I don't think it'll work for negative numbers.

sushensharma
Автор

This will fall if we put first element of array as largest number

asishr