Skip to content

Instantly share code, notes, and snippets.

@stephen-maina
Created April 14, 2015 10:17
Show Gist options
  • Save stephen-maina/c7cfc512418e16e3ffa2 to your computer and use it in GitHub Desktop.
Save stephen-maina/c7cfc512418e16e3ffa2 to your computer and use it in GitHub Desktop.
import java.util.stream.IntStream;
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
int[]sorted=IntStream.of(A).sorted().toArray();
for(int index=2;index<sorted.length;index++){
long ind1=(long)sorted[index];
long ind2=(long)sorted[index-1];
long ind3=(long)sorted[index-2];
if(ind3+ind2>ind1&&ind1+ind2>ind3&&ind3+ind1>ind2){
return 1;
}
}
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment