[codility]Triangle

最近在学scala语言,scala代码如下:

import scala.collection.JavaConversions._

object Solution {
    def solution(A: Array[Int]): Int = {
        // write your code in Scala 2.10
        // sort
        scala.util.Sorting.quickSort(A)
        // enumerate each most possible triangle edges combination
        for(i <- 2 to A.length-1) {
            if(A(i-2)>A(i)-A(i-1)) return 1
        }
        return 0
    }
}


你可能感兴趣的:([codility]Triangle)