MySpace Interview Question: In .net take a list of intege... | Glassdoor

Interview Question

Senior Developer Interview Los Angeles, CA

In .net take a list of integers and return the smallest one

  there,
Answer

Interview Answer

1 Answer

0

public int test1(int[] intArray) {
int x;
if(intArray.length == 0) {
  return -1; //no array passed in
}
   x = inArray[0];
  for(int i =1; i <= intArray.length; i++) {
    if( x <= intArray[i]) {
      x = intArray[i];
    }
  }
     return intArray[i];
}

Interview Candidate on Jun 15, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.