Bit Contribution Method¶
Table of Contents¶
- 477. Total Hamming Distance (Medium)
- 1863. Sum of All Subset XOR Totals (Easy)
- 2425. Bitwise XOR of All Pairings (Medium)
- 2275. Largest Combination With Bitwise AND Greater Than Zero (Medium)
- 1835. Find XOR Sum of All Pairs Bitwise AND (Hard)
- 2505. Bitwise OR of All Subsequence Sums (Medium) 👑
- 3153. Sum of Digit Differences of All Pairs (Medium)
477. Total Hamming Distance¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, math, bit manipulation
1863. Sum of All Subset XOR Totals¶
-
LeetCode | LeetCode CH (Easy)
-
Tags: array, math, backtracking, bit manipulation, combinatorics, enumeration
1863. Sum of All Subset XOR Totals - Python Solution
from functools import reduce
from operator import or_
from typing import List
def subsetXORSum(nums: List[int]) -> int:
return reduce(or_, nums) << (len(nums) - 1)
if __name__ == "__main__":
nums = [5, 1, 6]
print(subsetXORSum(nums)) # 28
2425. Bitwise XOR of All Pairings¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, bit manipulation, brainteaser
2275. Largest Combination With Bitwise AND Greater Than Zero¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, hash table, bit manipulation, counting
1835. Find XOR Sum of All Pairs Bitwise AND¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: array, math, bit manipulation
2505. Bitwise OR of All Subsequence Sums¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, math, bit manipulation, brainteaser
3153. Sum of Digit Differences of All Pairs¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: array, hash table, math, counting