You are viewing a single comment's thread. Return to all comments →
Groovy w/ Java under the hood
def reader = System.in.newReader() def firstLine = reader.readLine().split() def n = firstLine[0] as Integer def k = firstLine[1] as Integer def count = 0 def abs = { Math.abs it } def nums = reader.readLine().split().collect { (it as int) } def set = [] as Set nums.each { set << it + k } nums.each { if (set.contains(it)) count += 1 } println count
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Groovy w/ Java under the hood