File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
excel-sheet-column-number Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ leetcode 测试
10
10
11
11
##### 包含的内容如下
12
12
13
+ https://leetcode.cn/problems/minimum-time-difference/
14
+
15
+ https://leetcode.cn/problems/excel-sheet-column-title/
16
+
17
+ https://leetcode.cn/problems/excel-sheet-column-number/
18
+
13
19
https://leetcode.cn/problems/minimum-area-rectangle-ii/
14
20
15
21
https://leetcode.cn/problems/minimum-area-rectangle
Original file line number Diff line number Diff line change
1
+ export default function titleToNumber ( columnTitle : string ) : number {
2
+ return columnTitle . length === 1
3
+ ? columnTitle . charCodeAt ( 0 ) - "A" . charCodeAt ( 0 ) + 1
4
+ : titleToNumber ( columnTitle . at ( - 1 ) ?? "" ) +
5
+ 26 * titleToNumber ( columnTitle . slice ( 0 , - 1 ) ) ;
6
+ }
Original file line number Diff line number Diff line change
1
+ export default function convertToTitle ( columnNumber : number ) : string {
2
+ return columnNumber > 26
3
+ ? convertToTitle ( Math . floor ( ( columnNumber - 1 ) / 26 ) ) +
4
+ convertToTitle ( ( columnNumber - 1 ) % 26 + 1 )
5
+ : String . fromCharCode ( "A" . charCodeAt ( 0 ) + columnNumber - 1 ) ;
6
+ }
Original file line number Diff line number Diff line change
1
+ export default function findMinDifference ( timePoints : string [ ] ) : number {
2
+ const n = timePoints . length ;
3
+ if ( n > 1440 ) {
4
+ return 0 ;
5
+ }
6
+ timePoints . sort ( ) ;
7
+ let ans = Number . MAX_VALUE ;
8
+ const t0Minutes = getMinutes ( timePoints [ 0 ] ) ;
9
+ let preMinutes = t0Minutes ;
10
+ for ( let i = 1 ; i < n ; ++ i ) {
11
+ const minutes = getMinutes ( timePoints [ i ] ) ;
12
+ ans = Math . min ( ans , minutes - preMinutes ) ; // 相邻时间的时间差
13
+ preMinutes = minutes ;
14
+ }
15
+ ans = Math . min ( ans , t0Minutes + 1440 - preMinutes ) ; // 首尾时间的时间差
16
+ return ans ;
17
+ }
18
+
19
+ function getMinutes ( t : string ) {
20
+ const a = t . split ( "" ) . map ( Number ) ;
21
+ return ( (
22
+ a [ 0 ]
23
+ ) * 10 + ( a [ 1 ] ) ) * 60 + ( a [ 3 ] ) * 10 + ( a [ 4 ] ) ;
24
+ }
You can’t perform that action at this time.
0 commit comments