Skip to content

Commit 450926c

Browse files
Merge pull request #4247 from andreionoie/patch0
Correct time complexity for CSES Subarray Sum
2 parents efc54aa + 14a7ee4 commit 450926c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

solutions/silver/cses-1661.mdx

+3-10
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ subarray with sum $x$. After every iteration, we just add our new prefix sum to
1919
the map.
2020

2121
## Implementation
22-
**Time Complexity:** $\mathcal{O}(N \log N)$
2322

24-
<LanguageSection>
23+
**Time Complexity:** $\mathcal{O}(N)$
2524

25+
<LanguageSection>
2626
<CPPSection>
2727

2828
```cpp
@@ -32,10 +32,6 @@ the map.
3232

3333
using namespace std;
3434

35-
/**
36-
* @author Qi Wang
37-
* (detemplifying courtesy to Kevin Sheng)
38-
*/
3935
int main() {
4036
ios_base::sync_with_stdio(0);
4137
cin.tie(0);
@@ -65,7 +61,6 @@ int main() {
6561
```
6662

6763
</CPPSection>
68-
6964
<JavaSection>
7065

7166
```java
@@ -114,12 +109,10 @@ public class SubarraySumsII {
114109
```
115110

116111
</JavaSection>
117-
118112
<PySection>
119113

120114
```py
121115
def main():
122-
123116
N, X = map(int, input().split())
124117
prefix, res = 0, 0
125118
mp = {0: 1} # mp[0] = 1
@@ -133,6 +126,6 @@ def main():
133126

134127
main()
135128
```
136-
</PySection>
137129

130+
</PySection>
138131
</LanguageSection>

0 commit comments

Comments
 (0)