Q) Find the lowest index of the largest element in an array
Example:
Array: 1,5,2,3,5,5
Output:
Lowest Index of max element= 2
public class ArrayMaxElementLowestIndex { public int lowestIndex (int [] sampleArray){ int index=0;//intitalize the index to zero for (int i=0; i<sampleArray.length; i++){ //running a loop through the length of the array if(sampleArray[i]>sampleArray[index]){ //compare each element to the element at "index" index= i;//if above condition if fulfilled replace index with i } } return (index+1); } }