1
# Runtime: 556 ms (Top 81.4%) | Memory: 30.00 MB (Top 97.8%)5
def canArrange(self, arr: List[int], k: int) -> bool:6
# The idea is to count the residues8
# If every residue has the counter residue9
# such that x+y == k,then we found a pair15
# Now since we have 0,1,2,.....k-1 as residues16
# If count[1] == count[k-1],pairs+=count[1]17
# since we have odd number of complimenting residues,18
# we should also care about residue=0 and residue=k//223
if count[i] != count[j]:28
if pairs > 0 and i == j:32
return pairs == n // 2