You are viewing a single comment's thread. Return to all comments →
I tried in brute force , some testcases failed to due to timeout, your solution made my job easier.
my bruteforce solution: from itertools import combinations
def print_max_bitwise_and(n, k): result = 0 max_ = 0 for i, j in combinations(range(1, n+1),2): result = i&j if result < k and max_<result: max_ = result print(max_)
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 →
I tried in brute force , some testcases failed to due to timeout, your solution made my job easier.
my bruteforce solution: from itertools import combinations