Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf69933

Browse files
authored
Updated tasks 1-22
1 parentb3a8167 commitbf69933

File tree

20 files changed

+146
-246
lines changed

20 files changed

+146
-246
lines changed

‎src/main/java/g0001_0100/s0001_two_sum/readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ public class Solution {
9797
}
9898
```
9999

100-
This implementation provides a solution to the Two Sum problem with a time complexity of O(n), where n is the number of elements in the input array.
100+
This implementation provides a solution to the Two Sum problem with a time complexity of O(n), where n is the number of elements in the input array.

‎src/main/java/g0001_0100/s0002_add_two_numbers/readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ public class Solution {
130130
}
131131
```
132132

133-
This implementation provides a solution to the Add Two Numbers problem using linked lists in Java.
133+
This implementation provides a solution to the Add Two Numbers problem using linked lists in Java.

‎src/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Medium
44

5-
Given a string`s`, find the length of the**longestsubstring** withoutrepeating characters.
5+
Given a string`s`, find the length of the**longest****substring** withoutduplicate characters.
66

77
**Example 1:**
88

99
**Input:** s = "abcabcbb"
1010

1111
**Output:** 3
1212

13-
**Explanation:** The answer is "abc", with the length of 3.
13+
**Explanation:** The answer is "abc", with the length of 3.Note that`"bca"` and`"cab"` are also correct answers.
1414

1515
**Example 2:**
1616

@@ -28,12 +28,6 @@ Given a string `s`, find the length of the **longest substring** without repeati
2828

2929
**Explanation:** The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
3030

31-
**Example 4:**
32-
33-
**Input:** s = ""
34-
35-
**Output:** 0
36-
3731
**Constraints:**
3832

3933
* <code>0 <= s.length <= 5 * 10<sup>4</sup></code>
@@ -100,4 +94,4 @@ public class Solution {
10094
}
10195
```
10296

103-
This implementation provides a solution to the Longest Substring Without Repeating Characters problem in Java.
97+
This implementation provides a solution to the Longest Substring Without Repeating Characters problem in Java.

‎src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ The overall run time complexity should be `O(log (m+n))`.
2222

2323
**Explanation:** merged array =[1,2,3,4] and median is (2 + 3) / 2 = 2.5.
2424

25-
**Example 3:**
26-
27-
**Input:** nums1 =[0,0], nums2 =[0,0]
28-
29-
**Output:** 0.00000
30-
31-
**Example 4:**
32-
33-
**Input:** nums1 =[], nums2 =[1]
34-
35-
**Output:** 1.00000
36-
37-
**Example 5:**
38-
39-
**Input:** nums1 =[2], nums2 =[]
40-
41-
**Output:** 2.00000
42-
4325
**Constraints:**
4426

4527
*`nums1.length == m`
@@ -115,4 +97,4 @@ public class Solution {
11597
}
11698
```
11799

118-
This implementation provides a solution to the Median of Two Sorted Arrays problem in Java with a runtime complexity of O(log(min(m, n))).
100+
This implementation provides a solution to the Median of Two Sorted Arrays problem in Java with a runtime complexity of O(log(min(m, n))).

‎src/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,22 @@
22

33
Medium
44

5-
Given a string`s`, return_thelongest palindromic substring_ in`s`.
5+
Given a string`s`, return_thelongest__palindromic_**substring** in`s`.
66

77
**Example 1:**
88

99
**Input:** s = "babad"
1010

11-
**Output:** "bab"**Note:** "aba" is also a valid answer.
11+
**Output:** "bab"
12+
13+
**Explanation:** "aba" is also a valid answer.
1214

1315
**Example 2:**
1416

1517
**Input:** s = "cbbd"
1618

1719
**Output:** "bb"
1820

19-
**Example 3:**
20-
21-
**Input:** s = "a"
22-
23-
**Output:** "a"
24-
25-
**Example 4:**
26-
27-
**Input:** s = "ac"
28-
29-
**Output:** "a"
30-
3121
**Constraints:**
3222

3323
*`1 <= s.length <= 1000`
@@ -94,4 +84,4 @@ public class Solution {
9484
}
9585
```
9686

97-
This implementation provides a solution to the Longest Palindromic Substring problem in Java.
87+
This implementation provides a solution to the Longest Palindromic Substring problem in Java.

‎src/main/java/g0001_0100/s0006_zigzag_conversion/readme.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ public class Solution {
104104
}
105105
```
106106

107-
This implementation provides a solution to the Zigzag Conversion problem in Java.
107+
This implementation provides a solution to the Zigzag Conversion problem in Java.

‎src/main/java/g0001_0100/s0007_reverse_integer/readme.md‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If rev
2424

2525
**Output:** 21
2626

27-
**Example 4:**
28-
29-
**Input:** x = 0
30-
31-
**Output:** 0
32-
3327
**Constraints:**
3428

3529
* <code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code>
@@ -93,4 +87,4 @@ public class Solution {
9387
}
9488
```
9589

96-
This implementation provides a solution to the Reverse Integer problem in Java.
90+
This implementation provides a solution to the Reverse Integer problem in Java.

‎src/main/java/g0001_0100/s0008_string_to_integer_atoi/readme.md‎

Lines changed: 37 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,115 +2,87 @@
22

33
Medium
44

5-
Implement the`myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s`atoi` function).
5+
Implement the`myAtoi(string s)` function, which converts a string to a 32-bit signed integer.
66

77
The algorithm for`myAtoi(string s)` is as follows:
88

9-
1. Read in and ignore any leading whitespace.
10-
2. 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.
11-
3. 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.
12-
4. 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).
13-
5. If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then clamp the integer so that it remains in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be clamped to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be clamped to <code>2<sup>31</sup> - 1</code>.
14-
6. Return the integer as the final result.
9+
1.**Whitespace**: Ignore any leading whitespace (`" "`).
10+
2.**Signedness**: Determine the sign by checking if the next character is`'-'` or`'+'`, assuming positivity if neither present.
11+
3.**Conversion**: Read the integer by skipping leading zeros until a non-digit character is encountered or the end of the string is reached. If no digits were read, then the result is 0.
12+
4.**Rounding**: If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then round the integer to remain in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be rounded to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be rounded to <code>2<sup>31</sup> - 1</code>.
1513

16-
**Note:**
17-
18-
* Only the space character`' '` is considered a whitespace character.
19-
***Do not ignore** any characters other than the leading whitespace or the rest of the string after the digits.
14+
Return the integer as the final result.
2015

2116
**Example 1:**
2217

2318
**Input:** s = "42"
2419

2520
**Output:** 42
2621

27-
**Explanation:** The underlined characters are what is read in, the caret is the current reader position.
22+
**Explanation:**
2823

24+
The underlined characters are what is read in and the caret is the current reader position.
2925
Step 1: "42" (no characters read because there is no leading whitespace)
30-
^
26+
^
3127
Step 2: "42" (no characters read because there is neither a '-' nor '+')
3228
^
3329
Step 3: "42" ("42" is read in)
34-
^
35-
36-
The parsed integer is 42. Since 42 is in the range[-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 42.
30+
^
3731

3832
**Example 2:**
3933

40-
**Input:** s = " -42"
34+
**Input:** s = " -042"
4135

42-
**Output:** -42
36+
**Output:**\-42
4337

4438
**Explanation:**
4539

46-
Step 1: " -42" (leading whitespace is read and ignored)
47-
^
48-
Step 2: " -42" ('-' is read, so the result should be negative)
49-
^
50-
Step 3: " -42" ("42" is read in)
51-
^
52-
The parsed integer is -42.
53-
54-
Since -42 is in the range[-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is -42.
40+
Step 1: "___-042" (leading whitespace is read and ignored)
41+
^
42+
Step 2: " -042" ('-' is read, so the result should be negative)
43+
^
44+
Step 3: " -042" ("042" is read in, leading zeros ignored in the result)
45+
^
5546

5647
**Example 3:**
5748

58-
**Input:** s = "4193 with words"
49+
**Input:** s = "1337c0d3"
5950

60-
**Output:**4193
51+
**Output:**1337
6152

6253
**Explanation:**
6354

64-
Step 1: "4193 with words" (no characters read because there is no leading whitespace)
55+
Step 1: "1337c0d3" (no characters read because there is no leading whitespace)
6556
^
66-
Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
57+
Step 2: "1337c0d3" (no characters read because there is neither a '-' nor '+')
6758
^
68-
Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit)
59+
Step 3: "1337c0d3" ("1337" is read in; reading stops because the next character is a non-digit)
6960
^
70-
The parsed integer is 4193.
71-
72-
Since 4193 is in the range[-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 4193.
7361

7462
**Example 4:**
7563

76-
**Input:** s = "words and 987"
64+
**Input:** s = "0-1"
7765

7866
**Output:** 0
7967

8068
**Explanation:**
8169

82-
Step 1: "words and 987" (no characters read because there is no leading whitespace)
70+
Step 1: "0-1" (no characters read because there is no leading whitespace)
8371
^
84-
Step 2: "words and 987" (no characters read because there is neither a '-' nor '+')
72+
Step 2: "0-1" (no characters read because there is neither a '-' nor '+')
8573
^
86-
Step 3: "words and 987" (reading stops immediately because there is a non-digit 'w')
87-
^
88-
The parsed integer is 0 because no digits were read.
89-
90-
Since 0 is in the range[-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 0.
74+
Step 3: "0-1" ("0" is read in; reading stops because the next character is a non-digit)
75+
^
9176

9277
**Example 5:**
9378

94-
**Input:** s = "-91283472332"
79+
**Input:** s = "words and 987"
9580

96-
**Output:**-2147483648
81+
**Output:**0
9782

9883
**Explanation:**
9984

100-
Step 1: "-91283472332" (no characters read because there is no leading whitespace)
101-
^
102-
Step 2: "-91283472332" ('-' is read, so the result should be negative)
103-
^
104-
Step 3: "-91283472332" ("91283472332" is read in)
105-
^
106-
The parsed integer is -91283472332.
107-
108-
Since -91283472332 is less than the lower bound of the range[-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is clamped to -2<sup>31</sup> = -2147483648.
109-
110-
**Constraints:**
111-
112-
*`0 <= s.length <= 200`
113-
*`s` consists of English letters (lower-case and upper-case), digits (`0-9`),`' '`,`'+'`,`'-'`, and`'.'`.
85+
Reading stops at the first non-digit character 'w'.
11486

11587
To solve the String to Integer (atoi) problem in Java using a`Solution` class, we'll follow these steps:
11688

@@ -181,4 +153,9 @@ public class Solution {
181153
}
182154
```
183155

184-
This implementation provides a solution to the String to Integer (atoi) problem in Java.
156+
This implementation provides a solution to the String to Integer (atoi) problem in Java.
157+
158+
**Constraints:**
159+
160+
*`0 <= s.length <= 200`
161+
*`s` consists of English letters (lower-case and upper-case), digits (`0-9`),`' '`,`'+'`,`'-'`, and`'.'`.

‎src/main/java/g0001_0100/s0009_palindrome_number/readme.md‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Easy
44

5-
Given an integer`x`, return`true` if`x` is palindrome integer.
6-
7-
An integer is a**palindrome** when it reads the same backward as forward. For example,`121` is palindrome while`123` is not.
5+
Given an integer`x`, return`true`_if_`x`_is a__**palindrome**__, and_`false`_otherwise_.
86

97
**Example 1:**
108

119
**Input:** x = 121
1210

13-
**Output:** true
11+
**Output:** true
12+
13+
**Explanation:** 121 reads as 121 from left to right and from right to left.
1414

1515
**Example 2:**
1616

@@ -28,12 +28,6 @@ An integer is a **palindrome** when it reads the same backward as forward. For e
2828

2929
**Explanation:** Reads 01 from right to left. Therefore it is not a palindrome.
3030

31-
**Example 4:**
32-
33-
**Input:** x = -101
34-
35-
**Output:** false
36-
3731
**Constraints:**
3832

3933
* <code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code>
@@ -97,4 +91,4 @@ public class Solution {
9791
}
9892
```
9993

100-
This implementation provides a solution to the Palindrome Number problem in Java.
94+
This implementation provides a solution to the Palindrome Number problem in Java.

‎src/main/java/g0001_0100/s0010_regular_expression_matching/readme.md‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,10 @@ The matching should cover the **entire** input string (not partial).
3333

3434
**Explanation:** ".\*" means "zero or more (\*) of any character (.)".
3535

36-
**Example 4:**
37-
38-
**Input:** s = "aab", p = "c\*a\*b"
39-
40-
**Output:** true
41-
42-
**Explanation:** c can be repeated 0 times, a can be repeated 1 time. Therefore, it matches "aab".
43-
44-
**Example 5:**
45-
46-
**Input:** s = "mississippi", p = "mis\*is\*p\*."
47-
48-
**Output:** false
49-
5036
**Constraints:**
5137

5238
*`1 <= s.length <= 20`
53-
*`1 <= p.length <=30`
39+
*`1 <= p.length <=20`
5440
*`s` contains only lowercase English letters.
5541
*`p` contains only lowercase English letters,`'.'`, and`'*'`.
5642
* It is guaranteed for each appearance of the character`'*'`, there will be a previous valid character to match.
@@ -116,4 +102,4 @@ public class Solution {
116102
}
117103
```
118104

119-
This implementation provides a solution to the Regular Expression Matching problem in Java.
105+
This implementation provides a solution to the Regular Expression Matching problem in Java.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp