LC2275. 按位与结果大于零的最长组合
题目链接:https://leetcode.cn/problems/largest-combination-with-bitwise-and-greater-than-zero/
题解
- 标准贪心题目,按位与最后结果要大于 1,对应选择的数字在某一个二进制位上都是 1。所以反过来统计每一个二进制位上为 1 的数字有几个,取最大就是最后的答案。
参考代码
1 | class Solution: |
LC2275. 按位与结果大于零的最长组合
题目链接:https://leetcode.cn/problems/largest-combination-with-bitwise-and-greater-than-zero/
1 | class Solution: |
LC2275. 按位与结果大于零的最长组合