File tree 3 files changed +33
-2
lines changed
solution/2300-2399/2395.Find Subarrays With Equal Sum
3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,17 @@ func findSubarrays(nums []int) bool {
130
130
### ** TypeScript**
131
131
132
132
``` ts
133
-
133
+ function findSubarrays(nums : number []): boolean {
134
+ const vis: Set <number > = new Set <number >();
135
+ for (let i = 1 ; i < nums .length ; ++ i ) {
136
+ const x = nums [i - 1 ] + nums [i ];
137
+ if (vis .has (x )) {
138
+ return true ;
139
+ }
140
+ vis .add (x );
141
+ }
142
+ return false ;
143
+ }
134
144
```
135
145
136
146
### ** ...**
Original file line number Diff line number Diff line change @@ -115,7 +115,17 @@ func findSubarrays(nums []int) bool {
115
115
### ** TypeScript**
116
116
117
117
``` ts
118
-
118
+ function findSubarrays(nums : number []): boolean {
119
+ const vis: Set <number > = new Set <number >();
120
+ for (let i = 1 ; i < nums .length ; ++ i ) {
121
+ const x = nums [i - 1 ] + nums [i ];
122
+ if (vis .has (x )) {
123
+ return true ;
124
+ }
125
+ vis .add (x );
126
+ }
127
+ return false ;
128
+ }
119
129
```
120
130
121
131
### ** ...**
Original file line number Diff line number Diff line change
1
+ function findSubarrays ( nums : number [ ] ) : boolean {
2
+ const vis : Set < number > = new Set < number > ( ) ;
3
+ for ( let i = 1 ; i < nums . length ; ++ i ) {
4
+ const x = nums [ i - 1 ] + nums [ i ] ;
5
+ if ( vis . has ( x ) ) {
6
+ return true ;
7
+ }
8
+ vis . add ( x ) ;
9
+ }
10
+ return false ;
11
+ }
You can’t perform that action at this time.
0 commit comments