@Geeshang Got it! Thanks for the quick reply! I didn't know we can use
char(int) to cast
char before! Thanks!
Posts made by bdeng3
RE: C++ easy understand solution with comment
@nguyenton68 The -1 at
m=-1is just a virtual index. For example, in the array
[-2, -1, 2, 1]and
k=1. We know that
-1+2==1. Therefore, whose index are
2. But on unordered_map m, their index are actually
2. The value on the left has a
-1in it. That's why we need to set
-1to suit for the case where we started counting from the very beginning.
RE: Easy C++ Solution with Explanations
I have two questions with regard to this problem. I tried to remove the
statickey word, and it won't pass, any suggestions?
And within the for loop, if we directly use
for(int i=0; i<Intervals.size()-1; i++), it won't work as well. We must declare
n=Intervals.size()first. Why..? It looks very confusing to me.