You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function lengthOfLongestSubstring(s:string):number {
@@ -46,12 +56,15 @@ function lengthOfLongestSubstring(s: string): number {
46
56
returnlongesSubstring;
47
57
}
48
58
```
49
-
</details>
50
59
51
-
##### 4. Median of Two Sorted Arrays
52
-
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
60
+
</details><!--module 3 code ends-->
61
+
</details><!--module 3 ends-->
53
62
54
-
The overall run time complexity should be O(log (m+n)).
63
+
<details>
64
+
<summary> <strong>4. Median of Two Sorted Arrays</strong> </summary>
65
+
66
+
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
67
+
55
68
```typescript
56
69
Example1:
57
70
Input: nums1= [1,3], nums2= [2]
@@ -72,6 +85,10 @@ nums2.length == n
72
85
1<=m+n<=2000
73
86
-106<=nums1[i], nums2[i] <=106
74
87
```
88
+
<!--module 4 code-->
89
+
<details>
90
+
<summary><strong>See solution</strong></summary>
91
+
75
92
```typescript
76
93
function findMedianSortedArrays(nums1:number[], nums2:number[]):number {
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
205
-
###### Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
206
-
```example
193
+
Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
194
+
195
+
```typescript
207
196
Example1:
208
197
Input: x=123
209
198
Output: 321
@@ -219,8 +208,11 @@ Output: 21
219
208
220
209
Constraints:
221
210
-231<=x<=231-1
222
-
223
211
```
212
+
<!--module 7 code-->
213
+
<details>
214
+
<summary><strong>See solution</strong></summary>
215
+
224
216
```typescript
225
217
function reverse(x:number):number {
226
218
let reversed:number=0;
@@ -240,28 +232,45 @@ function reverse(x:number):number {
240
232
241
233
}
242
234
```
243
-
01.04.2023:
244
-
##### 8. String to Integer (atoi)
245
-
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).
246
-
247
-
The algorithm for myAtoi(string s) is as follows:
248
-
249
-
Read in and ignore any leading whitespace.
250
-
Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
251
-
Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
252
-
Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
253
-
If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
254
-
Return the integer as the final result.
255
-
256
-
###### Note:
257
-
<ul>
258
-
<li>Only the space character ' ' is considered a whitespace character.</li>
259
-
<li>Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.</li>
260
-
</ul>
261
-
262
235
236
+
</details><!--module 7 code ends-->
237
+
</details><!--module 7 ends-->
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
<details>
248
+
<summary> <strong>8. String to Integer (atoi)</strong> </summary>
249
+
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).
263
250
264
-
```example
251
+
The algorithm for <strong>myAtoi(string s)</strong> is as follows:
252
+
253
+
Read in and ignore any leading whitespace.
254
+
255
+
Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
256
+
257
+
Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
258
+
259
+
260
+
Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
261
+
262
+
If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
263
+
264
+
Return the integer as the final result.
265
+
266
+
267
+
Note:
268
+
<ul>
269
+
<li>Only the space character ' ' is considered a whitespace character.</li>
270
+
<li>Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.</li>
271
+
</ul>
272
+
273
+
```typescript
265
274
266
275
Example1:
267
276
Input: s="42"
@@ -302,18 +311,21 @@ Step 3: "4193 with words" ("4193" is read in; reading stops because the next cha
0 commit comments