public class BiggestnumberInArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[] = {1,8,10,40,30,60,50,0,-2};
System.out.println("The biggest Item is : "+
new BiggestnumberInArray().findBiggestItem(arr));
}
public int findBiggestItem(int arr[]) {
int biggest=0;
for (int i : arr) {
if(biggest==0) {
biggest=i;
}
if(biggest < i) {
biggest = i;
}
}
return biggest;
}
}
Output:-
The biggest Item is : 60
Thursday, February 4, 2021
How to find biggest item in the array within constant time complexity
Subscribe to:
Post Comments (Atom)
How to find middle node of LinkedList without using extra memory in java
To find the middle node of a LinkedList without using extra memory in Java, you can use the "tortoise and hare" algorithm. This al...
-
public class ReverseArrayWithoutExtraMemory { public static void main(String[] args) { int arr[] = {1,2,3,4,5,6}; int swapArray[] =...
-
1) List Interface Implementation public interface List<T extends Comparable<T>> { public Node<T> getMi...
-
function data_change(field) { var check = true; var value = field.value; //get characters //check that all ch...
No comments:
Post a Comment