You are viewing a single comment's thread. Return to all comments →
kotlin version
fun maximumPerimeterTriangle(sticks: Array<Int>): Array<Int> { return sticks.sorted().windowed(size = 3, step = 1) .filter { (it[0] + it[1] > it[2]) && (it[0] + it[2] > it[1]) && (it[1] + it[2] > it[0])} .associateBy { it.sum() } .maxByOrNull { it.key }?.value?.toTypedArray() ?: arrayOf(-1) }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Perimeter Triangle
You are viewing a single comment's thread. Return to all comments →
kotlin version