File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
solution/1400-1499/1433.Check If a String Can Break Another String Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,26 @@ func checkIfCanBreak(s1 string, s2 string) bool {
136
136
}
137
137
```
138
138
139
+ ### ** TypeScript**
140
+
141
+ ``` ts
142
+ function checkIfCanBreak(s1 : string , s2 : string ): boolean {
143
+ const cs1: string [] = Array .from (s1 );
144
+ const cs2: string [] = Array .from (s2 );
145
+ cs1 .sort ();
146
+ cs2 .sort ();
147
+ const check = (cs1 : string [], cs2 : string []) => {
148
+ for (let i = 0 ; i < cs1 .length ; i ++ ) {
149
+ if (cs1 [i ] < cs2 [i ]) {
150
+ return false ;
151
+ }
152
+ }
153
+ return true ;
154
+ };
155
+ return check (cs1 , cs2 ) || check (cs2 , cs1 );
156
+ }
157
+ ```
158
+
139
159
### ** ...**
140
160
141
161
```
Original file line number Diff line number Diff line change @@ -123,6 +123,26 @@ func checkIfCanBreak(s1 string, s2 string) bool {
123
123
}
124
124
```
125
125
126
+ ### ** TypeScript**
127
+
128
+ ``` ts
129
+ function checkIfCanBreak(s1 : string , s2 : string ): boolean {
130
+ const cs1: string [] = Array .from (s1 );
131
+ const cs2: string [] = Array .from (s2 );
132
+ cs1 .sort ();
133
+ cs2 .sort ();
134
+ const check = (cs1 : string [], cs2 : string []) => {
135
+ for (let i = 0 ; i < cs1 .length ; i ++ ) {
136
+ if (cs1 [i ] < cs2 [i ]) {
137
+ return false ;
138
+ }
139
+ }
140
+ return true ;
141
+ };
142
+ return check (cs1 , cs2 ) || check (cs2 , cs1 );
143
+ }
144
+ ```
145
+
126
146
### ** ...**
127
147
128
148
```
Original file line number Diff line number Diff line change
1
+ function checkIfCanBreak ( s1 : string , s2 : string ) : boolean {
2
+ const cs1 : string [ ] = Array . from ( s1 ) ;
3
+ const cs2 : string [ ] = Array . from ( s2 ) ;
4
+ cs1 . sort ( ) ;
5
+ cs2 . sort ( ) ;
6
+ const check = ( cs1 : string [ ] , cs2 : string [ ] ) => {
7
+ for ( let i = 0 ; i < cs1 . length ; i ++ ) {
8
+ if ( cs1 [ i ] < cs2 [ i ] ) {
9
+ return false ;
10
+ }
11
+ }
12
+ return true ;
13
+ } ;
14
+ return check ( cs1 , cs2 ) || check ( cs2 , cs1 ) ;
15
+ }
You can’t perform that action at this time.
0 commit comments