Largest Element in Array Solution
Anonymous
c_cpp
04/16/2024 5:56 AM
364 B
37
Indexable
#include <bits/stdc++.h>
int largestElement(vector<int> &arr, int n) {
// Write your code here.
int largest = 0;
for(int i = 1; i< n; i++){
if(arr[i] > arr[largest]){
largest = i;
}
}
return arr[largest];
}
Editor is loading...
Leave a Comment