File tree 6 files changed +57
-8
lines changed
2500-2599/2580.Count Ways to Group Overlapping Ranges
6 files changed +57
-8
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,24 @@ func countWays(ranges [][]int) int {
251
251
}
252
252
```
253
253
254
+ ### ** TypeScript**
255
+
256
+ ``` ts
257
+ function countWays(ranges : number [][]): number {
258
+ ranges .sort ((a , b ) => a [0 ] - b [0 ]);
259
+ let mx = - 1 ;
260
+ let ans = 1 ;
261
+ const mod = 10 ** 9 + 7 ;
262
+ for (const [start, end] of ranges ) {
263
+ if (start > mx ) {
264
+ ans = (ans * 2 ) % mod ;
265
+ }
266
+ mx = Math .max (mx , end );
267
+ }
268
+ return ans ;
269
+ }
270
+ ```
271
+
254
272
### ** ...**
255
273
256
274
```
Original file line number Diff line number Diff line change @@ -233,6 +233,24 @@ func countWays(ranges [][]int) int {
233
233
}
234
234
```
235
235
236
+ ### ** TypeScript**
237
+
238
+ ``` ts
239
+ function countWays(ranges : number [][]): number {
240
+ ranges .sort ((a , b ) => a [0 ] - b [0 ]);
241
+ let mx = - 1 ;
242
+ let ans = 1 ;
243
+ const mod = 10 ** 9 + 7 ;
244
+ for (const [start, end] of ranges ) {
245
+ if (start > mx ) {
246
+ ans = (ans * 2 ) % mod ;
247
+ }
248
+ mx = Math .max (mx , end );
249
+ }
250
+ return ans ;
251
+ }
252
+ ```
253
+
236
254
### ** ...**
237
255
238
256
```
Original file line number Diff line number Diff line change
1
+ function countWays ( ranges : number [ ] [ ] ) : number {
2
+ ranges . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] ) ;
3
+ let mx = - 1 ;
4
+ let ans = 1 ;
5
+ const mod = 10 ** 9 + 7 ;
6
+ for ( const [ start , end ] of ranges ) {
7
+ if ( start > mx ) {
8
+ ans = ( ans * 2 ) % mod ;
9
+ }
10
+ mx = Math . max ( mx , end ) ;
11
+ }
12
+ return ans ;
13
+ }
Original file line number Diff line number Diff line change 11
11
12
12
| 段位 | 比例 | 段位名 | 国服分数线 | 勋章 |
13
13
| ----- | ------ | -------- | --------- | --------------------------------------------------------------------------- |
14
- | LV3 | 5% | Guardian | &ge ; 2265.64 | <p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Guardian.gif " style =" width : 80px ;" /></p > |
15
- | LV2 | 20% | Knight | &ge ; 1894.28 | <p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Knight.gif " style =" width : 80px ;" /></p > |
14
+ | LV3 | 5% | Guardian | &ge ; 2251.88 | <p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Guardian.gif " style =" width : 80px ;" /></p > |
15
+ | LV2 | 20% | Knight | &ge ; 1879.80 | <p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Knight.gif " style =" width : 80px ;" /></p > |
16
16
| LV1 | 75% | - | - | - |
17
17
18
18
力扣竞赛 ** 全国排名前 10** 的用户,全站用户名展示为品牌橙色。
Original file line number Diff line number Diff line change @@ -127,8 +127,8 @@ def generate_contest_list():
127
127
128
128
| 段位 | 比例 | 段位名 | 国服分数线 | 勋章 |
129
129
| ----- | ------ | -------- | --------- | --------------------------------------------------------------------------- |
130
- | LV3 | 5% | Guardian | ≥2265.64 | <p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Guardian.gif" style="width: 80px;" /></p> |
131
- | LV2 | 20% | Knight | ≥1894.28 | <p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Knight.gif" style="width: 80px;" /></p> |
130
+ | LV3 | 5% | Guardian | ≥2251.88 | <p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Guardian.gif" style="width: 80px;" /></p> |
131
+ | LV2 | 20% | Knight | ≥1879.80 | <p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/images/Knight.gif" style="width: 80px;" /></p> |
132
132
| LV1 | 75% | - | - | - |
133
133
134
134
力扣竞赛 **全国排名前 10** 的用户,全站用户名展示为品牌橙色。
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ def get_user_ranking(self, uid):
104
104
return None
105
105
106
106
def get_1600_count (self ):
107
- left , right = 1 , 1000 if self . region == 'CN' else 3000
107
+ left , right = 1 , 4000
108
108
while left < right :
109
109
mid = (left + right + 1 ) >> 1
110
110
page = self .load_page (mid )
@@ -116,17 +116,17 @@ def get_1600_count(self):
116
116
left = mid
117
117
else :
118
118
right = mid - 1
119
- page = self .load_page (left )
119
+ page = [ uid for _ , uid in self .load_page (left ) if uid ]
120
120
print ('校准中...' )
121
121
left , right = 0 , len (page ) - 1
122
122
while left < right :
123
123
mid = (left + right + 1 ) >> 1
124
- ranking , score = self .get_user_ranking (page [mid ][ 1 ] )
124
+ ranking , score = self .get_user_ranking (page [mid ])
125
125
if score >= 1600 :
126
126
left = mid
127
127
else :
128
128
right = mid - 1
129
- return self .get_user_ranking (page [left ][ 1 ] )[0 ]
129
+ return self .get_user_ranking (page [left ])[0 ]
130
130
131
131
def get_user (self , rank ):
132
132
p = (rank - 1 ) // 25 + 1
You can’t perform that action at this time.
0 commit comments