diff --git a/solved/LeetCode/Challenges/2020/January/25.kt b/solved/LeetCode/Challenges/2020/January/25.kt new file mode 100644 index 00000000..5e14749d --- /dev/null +++ b/solved/LeetCode/Challenges/2020/January/25.kt @@ -0,0 +1,16 @@ +class Solution { + fun kLengthApart(nums: IntArray, k: Int): Boolean { + var posOnes = mutableListOf() + for ((i, v) in nums.withIndex()) { + if (v == 1) { + posOnes.add(i) + } + } + for (i in 1 until posOnes.size) { + if (posOnes[i] - posOnes[i - 1] <= k) { + return false + } + } + return true + } +}