One of the common programming questions is, how do you find the largest and smallest number in N numbers without using arrays in Java? Can you write a program to solve this problem? Well, it's very similar to the problem we have seen before, find the largest and smallest of 3 integers. You can use the same approach and generalize it for N numbers. All you need to do is start with largest as Integer.MIN_VALUE and smallest number as Integer.MAX_VALUE and loop through N numbers. At each iteration, compare the number with the largest and smallest number, if the current number is larger than largest than its a new largest and if the current number is smaller than smallest than its a new smallest number.
Read more »
Anda baru saja membaca artikel yang berkategori Coding Interview Question |
core java
dengan judul Printing Largest and Smallest of N numbers without using Array in Java. Jika kamu suka, janganlike dan bagikan keteman-temanmu ya... By : En Kolay Yolu
Ditulis oleh:
Adsız -


Belum ada komentar untuk "Printing Largest and Smallest of N numbers without using Array in Java"
Yorum Gönder