Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eef6fad

Browse files
Update 3624.Number-of-Integers-With-Popcount-Depth-Equal-to-K-II.cpp
1 parent d447a82 commit eef6fad

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎Segment_Tree/3624.Number-of-Integers-With-Popcount-Depth-Equal-to-K-II/3624.Number-of-Integers-With-Popcount-Depth-Equal-to-K-II.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class Solution {
5555

5656
vector<int> popcountDepth(vector<long long>& nums, vector<vector<long long>>& queries) {
5757
int N = nums.size()+1;
58-
vector<BIT> bit_arr (6);
59-
for (int i=0; i<=5; i++)
58+
vector<BIT> bit_arr (5);
59+
for (int i=0; i<=4; i++)
6060
bit_arr[i].init(N);
61-
61+
6262
for (int i=0; i<nums.size(); i++) {
6363
int depth = getDepth(nums[i]);
6464
bit_arr[depth].updateDelta(i+1, 1);
@@ -75,7 +75,10 @@ class Solution {
7575
nums[idx] = val;
7676
} else {
7777
int l = q[1], r = q[2], k = q[3];
78-
rets.push_back(bit_arr[k].sumRange(l+1,r+1));
78+
if (k>=5)
79+
rets.push_back(0);
80+
else
81+
rets.push_back(bit_arr[k].sumRange(l+1,r+1));
7982
}
8083
}
8184

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /