Skip to content

Instantly share code, notes, and snippets.

@stephen-maina
Created April 13, 2015 05:46
Show Gist options
  • Save stephen-maina/59180bcc105b9ad747ee to your computer and use it in GitHub Desktop.
Save stephen-maina/59180bcc105b9ad747ee to your computer and use it in GitHub Desktop.
PermCheck lesson 2 codility
import java.util.stream.IntStream;
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
if(A.length==0){
return 0;
}
int[] sorted=IntStream.of(A).sorted().toArray();
for(int index=0;index<sorted.length;index++){
int check=index+1;
if(sorted[index]!=check){
return 0;
}
}
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment