Wäre auch meine Lösung...
Zur Bestätigung:
import java.sql.*;
import java.io.*;
public class Test1{
static int n[] = {11,3,5,2,7,9};
public static void main(String args[]){
System.out.println(function(n));
}
protected static int function ( int v[] )
{
int I = 0, l = v.length - 1;
for(;!(v[I]>=v[l--]&&++l==I++) ; ) {
System.out.println("I: "+I);
System.out.println("l: "+l);
};
return v[l];
}
}[/PHP]
liefert als Ausgabe:
I: 1
l: 5
I: 1
l: 4
I: 1
l: 3
I: 2
l: 3
I: 3
l: 3
2
Gruß Jaraz