File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > </ title >
6+ </ head >
7+ < body >
8+ < script type ="text/javascript ">
9+ /**
10+ * @param {string } s
11+ * @param {number } n
12+ * @return {string }
13+ */
14+ var convert = function ( s , n ) {
15+ let res = '' ;
16+ let len = s . length ;
17+ if ( n == 1 ) return s ;
18+ for ( let i = 0 ; i < n ; i ++ ) {
19+ if ( i == 0 || i == n - 1 ) {
20+ for ( let j = i ; j < len ; j += 2 * n - 2 ) {
21+ res += s . charAt ( j ) ;
22+ }
23+ } else {
24+ for ( let j = i , k = 2 * n - 2 - i ; j < len || k < len ; j += 2 * n - 2 , k += 2 * n - 2 ) {
25+ if ( j < len ) res += s . charAt ( j ) ;
26+ if ( k < len ) res += s . charAt ( k ) ;
27+ }
28+ }
29+ }
30+ return res ;
31+ } ;
32+ </ script >
33+ </ body >
34+ </ html >
Original file line number Diff line number Diff line change 1+ childrenString ( str ) {
2+ let match = ( str ) => {
3+ let j = str . match ( / ^ ( 0 + | 1 + ) / ) [ 0 ]
4+ let o = ( j [ 0 ] ^ 1 ) . toString ( ) . repeat ( j . length )
5+ let reg = new RegExp ( `^(${ j } ${ o } )` )
6+ if ( reg . test ( str ) ) {
7+ return RegExp . $1
8+ } else {
9+ return ''
10+ }
11+ }
12+ let r = [ ]
13+ for ( let i = 0 , len = str . length - 1 ; i < len ; i ++ ) {
14+ let sub = match ( str . slice ( i ) ) )
15+ if ( sub ) {
16+ r . push ( sub )
17+ }
18+ }
19+ cehsicehih
20+ return r
21+ }
You can’t perform that action at this time.
0 commit comments