-
1310. XOR Queries of a Subarray릿코드(LEETCODE) 2020. 2. 16. 16:55반응형
https://leetcode.com/problems/xor-queries-of-a-subarray/
Source
class Solution { public: vector<int> xorQueries(vector<int>& arr, vector<vector<int>>& queries) { vector<int> result; for (int i = 0; i < queries.size(); i++) { int left = queries[i][0]; int right = queries[i][1]; int cand = arr[left]; for (int j = left; j < right; j++) { cand = cand ^ arr[j+1]; } result.push_back(cand); } return result; } };
반응형'릿코드(LEETCODE)' 카테고리의 다른 글
463. Island Perimeter (0) 2020.03.03 1207. Unique Number of Occurrences (0) 2020.02.28 1309. Decrypt String from Alphabet to Integer Mapping (0) 2020.02.16 1352. Product of the Last K Numbers (0) 2020.02.16 1143. Longest Common Subsequence (0) 2020.02.15