leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

A problem about 315. Count of Smaller Numbers After Self

Open guuzaa opened this issue 5 years ago • 1 comments

Hi, there.

In the Binary Index Tree implementation, the length of the tree should be one greater than the length of the original array (nums) . However, your code is the same .

// @ 63-64 line
vector <int> f(sorted.size());
fenwick = f;

I think this will lead to some memory overflow issues. So, I modifies the size of f to sorted.size() + 1. It works in leetcode.

guuzaa avatar Oct 05 '20 13:10 guuzaa

Yes Binary Index Tree is always one greater than the size of the array

Shanayshah44 avatar Nov 08 '23 14:11 Shanayshah44