We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
c++ solution
int bitwiseAnd(int N, int K) {
int max_val = 0;
for (int A = 1; A <= N; A++) {
for (int B = A + 1; B <= N; B++) {
int current_val = A & B;
if (current_val < K && current_val > max_val) {
max_val = current_val;
}
}
}
return max_val;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
c++ solution int bitwiseAnd(int N, int K) { int max_val = 0;
}