You are viewing a single comment's thread. Return to all comments →
fun nonDivisibleSubset(k: Int, s: Array<Int>): Int { val d = IntArray(k) {0} for (i in s.indices) { val rem = s[i] % k d[rem]++ } val k2 = k / 2 var r = Math.min(1, d[0]) for (i in 1..k2) { if (k % 2 == 0 && i == k2) { r += Math.min(1, d[i]) } else { val r1 = d[i] val r2 = d[k - i] val rm = Math.max(r1, r2) r += rm } } return r }
Seems like cookies are disabled on this browser, please enable them to open this website
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →