Find out Max and Min number out of three positive numbers - Quick Trick

preview_player
Показать описание
In this video, I have explained how to Find out Max and Min number out of three positive numbers - Quick Trick

Schedule a meeting in case of any queries/guidance/counselling:

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Naveen AutomationLabs Paid Courses:
GIT Hub Course:

Java & Selenium:

Java & API +POSTMAN + RestAssured + HttpClient:
Рекомендации по теме
Комментарии
Автор

Nice solution with simple logic 👍
Thank you.

karishmasamantaaray
Автор

Ain't the time complexity high for this solution, it is running the while loop n number of times which can be even 100. Just a thought

prachidhingra
Автор

thanks Naveen ...is my solution ok for the obvious solution you mentioned at the end ?
private static void findMaxMin(int i, int j, int k) {
if(i>=j && i>=k)
System.out.println("max is "+i);
else if(j>=i && j>=k)
System.out.println("max is "+j);
else
System.out.println("max is "+k);
if(i<=j && i<=k)
System.out.println("min is "+i);
else if(j<=i && j<=k)
System.out.println("min is "+j);
else
System.out.println("min is "+k);
}

GyandevShukla
Автор

We can also get this using Math.max() or Math.min() library right?

pratikbhowmik
Автор

private static int min(int a, int b) {
return ((a <= b) ? a : b);
}
private static int max(int a, int b) {
return ((a >= b) ? a : b);
}

public static void main(String[] args) {

int minval = min(17, min(2, 3));
System.out.println("Minimum value: " + minval);

int maxval = max(17, min(2, 3));
System.out.println("Maximum value: " + maxval);
}

jwalakumar