| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- zeros
- 컴퓨터과학과
- mpnp
- 기본
- Plotting
- 조지아텍
- 방송통신대학교
- 매트랩
- omscs
- LAA
- 캐나다 영주권
- leetcode
- 딥러닝
- C++
- 프로그래머스
- LV1
- 주정부이민
- 방통대
- 온라인석사
- Deep learning
- 머신러닝
- 위니펙
- 코딩테스트
- 선형대수
- MATLAB
- cpp
- EOI
- 알고리즘
- 개발자
- machine learning
Archives
- Today
- Total
Byte by Byte
1863. Sum of All Subset XOR Totals.cpp 본문
난이도가 높아지니까, dp알고리즘 활용 문제가 자꾸 나온다 😕
//thanks to https://www.youtube.com/watch?v=CJ9EicV9nWc&ab_channel=CODE_CROSING
class Solution {
public:
int subsetXORSum(vector<int>& nums) {
return helper(nums, 0,0);
}
int helper(vector<int>&nums,int level, int currentXOR){
if(level == nums.size()) return currentXOR;
int inc = helper(nums,level +1,currentXOR^nums[level]);
int exc = helper(nums,level +1,currentXOR);
return inc + exc;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
| 1309. Decrypt String from Alphabet to Integer Mapping.cpp (0) | 2021.10.05 |
|---|---|
| 1827. Minimum Operations to Make the Array Increasing.cpp (0) | 2021.10.05 |
| 1382. Balance a Binary Search Tree.cpp (0) | 2021.10.04 |
| 763. Partition Labels.cpp (0) | 2021.10.03 |
| 1605. Find Valid Matrix Given Row and Column Sums.cpp (0) | 2021.10.03 |