
N has a range of 1 to 2 * 10^ 5
A brute force for the problem is below. Time Complexity (O(N^2))
int sum = 0;
for(int i = 0 ; i < N ; ++i)
for(int j = i + 1 ; j < N ; ++j)
sum = (sum + ((i & j) ? 0 : i * j)) % 1000000007;
return sum;But this gives TLE for large N. What is the efficient way of solving this and what is the time complexity.