File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
count-nice-pairs-in-an-array Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ Step 2. Add the dependency
49
49
50
50
<summary >展开查看</summary >
51
51
52
+ https://leetcode-cn.com/problems/count-nice-pairs-in-an-array/
53
+
52
54
https://leetcode-cn.com/problems/sentence-similarity-iii/
53
55
54
56
https://leetcode.cn/problems/min-max-game/
Original file line number Diff line number Diff line change
1
+ function countNicePairs ( nums : number [ ] ) : number {
2
+
3
+ const MOD = 1000000007 ;
4
+ let res = 0 ;
5
+ const h = new Map < number , number > ( ) ;
6
+ for ( const i of nums ) {
7
+ let temp = i , j = 0 ;
8
+ while ( temp > 0 ) {
9
+ j = j * 10 + temp % 10 ;
10
+ temp = Math . floor ( temp / 10 ) ;
11
+ }
12
+ res = ( res + ( h . get ( i - j ) || 0 ) ) % MOD ;
13
+ h . set ( i - j , ( h . get ( i - j ) || 0 ) + 1 ) ;
14
+ }
15
+ return res ;
16
+ } ;
17
+ export default countNicePairs
You can’t perform that action at this time.
0 commit comments