3954. Sum of Compatible Numbers in Range I
You are given two integers
nandk.A positive integer
xis called compatible if it satisfies both of the following conditions:
abs(n - x) <= k(n & x) == 0Return the sum of all compatible integers
x.Note:
- Here,
&denotes the bitwise AND operator.- The absolute difference between integers
iandjis defined asabs(i - j).
1 | class Solution { |