help needed in that question, link of the question : Hotel rooms
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
help needed in that question, link of the question : Hotel rooms
How to find total number of subarrays with sum atmost k?
Constrains :
-1e4 <= a[i] <= 1e4
1 <= n <= 1e5
This is my Code
This is the problem
Why I'm getting Run Time Error, I'm not able to find why, someone please look into my code.
Got Ac thanks to AC_AC
We are given an array of n elements and I want to count the total no of such four variables with a sum equal to K, I tried it using multi-map where I store all key-value key(sum of pairs) and value(pair{i,j}) and then two-pointer, I am confused in the case when the sum of two pairs is equal to K, then where I will go (right to I, or left to j) cause If I move in both direction the time complexity will increase, and there are overlapping cases too if I store the frequency of each pair sum.
Name |
---|