1def return_largest_element(array):
2 largest = 0
3 for x in range(0, len(array)):
4 if(array[x] > largest):
5 largest = array[x]
6 return largest
1---without sort method---
2public static int maxValue( int[] n ) {
3
4int max = Integer.MIN_VALUE;
5
6for(int each: n)
7
8if(each > max)
9
10max = each;
11
12
13return max;
14
15---with sort method---
16public static int maxValue( int[] n ) {
17
18Arrays.sort( n );
19
20return n [ n.lenth-1 ];
21
22}
1int max;
2max=INT_MIN;
3
4for(int i=0;i<ar.length();i++){
5 if(ar[i]>max){
6 max=ar[i];
7 }
8
9