arr
by absolute values.count
to store the frequency of each element in arr
.x
, check if count[x]
is greater than 0.
b. If so, check if count[2*x]
is also greater than 0.
c. If both counts are positive, decrement count[x]
and count[2*x]
by 1.
d. If count[2*x]
is not positive, return false
as we cannot pair x
with 2*x
.false
, return true
.