2356. Largest Combination With Bitwise AND Greater Than Zero
My accepted Python solution to LeetCode problem 2356, Largest Combination With Bitwise AND Greater Than Zero, running in 496ms.
- Difficulty: Medium
- Python
- Runtime 496ms
- Memory 25MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 496ms, memory 25MB, accepted 2026-01-02.
class Solution:
def largestCombination(self, candidates: List[int]) -> int:
result = 0
for bit in range(24): # Numbers up to 10^7 need at most 24 bits
count = sum(1 for num in candidates if num & (1 << bit))
result = max(result, count)
return result