Any faster way to pick minimum number from an integer array?
For example I have an array like below:
int[] arrayOne = new int[10]{1,3,5,2,4,7,10,29,38,42};
And below are my method to pick the minimum number from the array
int pickMinNumber (int[] intArray)
{
int result = intArray[0];
for (int i = 0; i < arrayOne.Length - 1; i++)
{
if(intArray[i] < result)
result = intArray[i];
}
return result;
}
Are there any quicker way to pick the minimum number?
For example I have an array like below:
int[] arrayOne = new int[10]{1,3,5,2,4,7,10,29,38,42};
And below are my method to pick the minimum number from the array
int pickMinNumber (int[] intArray)
{
int result = intArray[0];
for (int i = 0; i < arrayOne.Length - 1; i++)
{
if(intArray[i] < result)
result = intArray[i];
}
return result;
}
Are there any quicker way to pick the minimum number?
No comments:
Post a Comment