Last active
August 8, 2020 01:59
-
-
Save kimji1/9e826a14616a3b0075e4a68a704f1f24 to your computer and use it in GitHub Desktop.
codility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| println(solution(intArrayOf(-6, -91, 1011, -100, 84, -22, 0, 1, 473))) | |
| } | |
| fun solution(A: IntArray): Int { | |
| val oneDigits = A.filter { it < 10 && it > -10 } | |
| var max = oneDigits[0] | |
| oneDigits.forEach { | |
| if (it > max) { | |
| max = it | |
| } | |
| } | |
| return max | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment