Skip to content

Commit d7e8641

Browse files
committed
Updated java and kotlin tasks
1 parent f9ef4ce commit d7e8641

File tree

95 files changed

+775
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+775
-592
lines changed

README.md

Lines changed: 156 additions & 152 deletions
Large diffs are not rendered by default.

src/main/kotlin/g0001_0100/s0001_two_sum/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can return the answer in any order.
1717

1818
**Output:** [0,1]
1919

20-
**Explanation:** Because nums[0] + nums[1] == 9, we return [0, 1].
20+
**Output:** Because nums[0] + nums[1] == 9, we return [0, 1].
2121

2222
**Example 2:**
2323

@@ -38,7 +38,7 @@ You can return the answer in any order.
3838
* <code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code>
3939
* **Only one valid answer exists.**
4040

41-
**Follow-up:** Can you come up with an algorithm that is less than <code>O(n<sup>2</sup>)</code> time complexity?
41+
**Follow-up:** Can you come up with an algorithm that is less than <code>O(n<sup>2</sup>) </code>time complexity?
4242

4343
## Solution
4444

src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring/readme.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ class Solution {
5353
var lpsCenter = 0
5454
var lpsRadius = 0
5555
for (i in newStr.indices) {
56-
dp[i] = if (friendCenter + friendRadius > i) Math.min(
57-
dp[friendCenter * 2 - i],
58-
friendCenter + friendRadius - i
59-
) else 1
56+
dp[i] = if (friendCenter + friendRadius > i) {
57+
Math.min(
58+
dp[friendCenter * 2 - i],
59+
friendCenter + friendRadius - i,
60+
)
61+
} else {
62+
1
63+
}
6064
while (i + dp[i] < newStr.size && i - dp[i] >= 0 && newStr[i + dp[i]] == newStr[i - dp[i]]) {
6165
dp[i]++
6266
}

src/main/kotlin/g0001_0100/s0010_regular_expression_matching/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Solution {
8989
i,
9090
j - 2,
9191
s,
92-
p
92+
p,
9393
)
9494
}
9595
} else {

src/main/kotlin/g0001_0100/s0017_letter_combinations_of_a_phone_number/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ A mapping of digit to letters (just like on the telephone buttons) is given belo
1515

1616
**Input:** digits = "23"
1717

18-
**Output:** ["ad","ae","af","bd","be","bf","cd","ce","cf"]
18+
**Output:** ["ad","ae","af","bd","be","bf","cd","ce","cf"]
1919

2020
**Example 2:**
2121

2222
**Input:** digits = ""
2323

24-
**Output:** []
24+
**Output:** []
2525

2626
**Example 3:**
2727

2828
**Input:** digits = "2"
2929

30-
**Output:** ["a","b","c"]
30+
**Output:** ["a","b","c"]
3131

3232
**Constraints:**
3333

@@ -52,7 +52,7 @@ class Solution {
5252
nums: String,
5353
letters: Array<String>,
5454
curr: StringBuilder,
55-
ans: MutableList<String>
55+
ans: MutableList<String>,
5656
) {
5757
if (curr.length == nums.length) {
5858
ans.add(curr.toString())

src/main/kotlin/g0001_0100/s0019_remove_nth_node_from_end_of_list/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Given the `head` of a linked list, remove the `nth` node from the end of the lis
1313

1414
**Input:** head = [1,2,3,4,5], n = 2
1515

16-
**Output:** [1,2,3,5]
16+
**Output:** [1,2,3,5]
1717

1818
**Example 2:**
1919

2020
**Input:** head = [1], n = 1
2121

22-
**Output:** []
22+
**Output:** []
2323

2424
**Example 3:**
2525

2626
**Input:** head = [1,2], n = 1
2727

28-
**Output:** [1]
28+
**Output:** [1]
2929

3030
**Constraints:**
3131

src/main/kotlin/g0001_0100/s0020_valid_parentheses/readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ An input string is valid if:
1616

1717
**Input:** s = "()"
1818

19-
**Output:** true
19+
**Output:** true
2020

2121
**Example 2:**
2222

2323
**Input:** s = "()[]{}"
2424

25-
**Output:** true
25+
**Output:** true
2626

2727
**Example 3:**
2828

2929
**Input:** s = "(]"
3030

31-
**Output:** false
31+
**Output:** false
3232

3333
**Example 4:**
3434

3535
**Input:** s = "([)]"
3636

37-
**Output:** false
37+
**Output:** false
3838

3939
**Example 5:**
4040

4141
**Input:** s = "{[]}"
4242

43-
**Output:** true
43+
**Output:** true
4444

4545
**Constraints:**
4646

src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Merge two sorted linked lists and return it as a **sorted** list. The list shoul
1313

1414
**Input:** l1 = [1,2,4], l2 = [1,3,4]
1515

16-
**Output:** [1,1,2,3,4,4]
16+
**Output:** [1,1,2,3,4,4]
1717

1818
**Example 2:**
1919

2020
**Input:** l1 = [], l2 = []
2121

22-
**Output:** []
22+
**Output:** []
2323

2424
**Example 3:**
2525

2626
**Input:** l1 = [], l2 = [0]
2727

28-
**Output:** [0]
28+
**Output:** [0]
2929

3030
**Constraints:**
3131

src/main/kotlin/g0001_0100/s0022_generate_parentheses/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Given `n` pairs of parentheses, write a function to _generate all combinations o
1111

1212
**Input:** n = 3
1313

14-
**Output:** ["((()))","(()())","(())()","()(())","()()()"]
14+
**Output:** ["((()))","(()())","(())()","()(())","()()()"]
1515

1616
**Example 2:**
1717

1818
**Input:** n = 1
1919

20-
**Output:** ["()"]
20+
**Output:** ["()"]
2121

2222
**Constraints:**
2323

src/main/kotlin/g0001_0100/s0023_merge_k_sorted_lists/readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ _Merge all the linked-lists into one sorted linked-list and return it._
1515

1616
**Output:** [1,1,2,3,4,4,5,6]
1717

18-
**Explanation:** The linked-lists are: [ 1->4->5, 1->3->4, 2->6 ] merging them into one sorted list: 1->1->2->3->4->4->5->6
18+
**Explanation:** The linked-lists are: [ 1->4->5, 1->3->4, 2->6 ] merging them into one sorted list: 1->1->2->3->4->4->5->6
1919

2020
**Example 2:**
2121

2222
**Input:** lists = []
2323

24-
**Output:** []
24+
**Output:** []
2525

2626
**Example 3:**
2727

2828
**Input:** lists = \[\[]]
2929

30-
**Output:** []
30+
**Output:** []
3131

3232
**Constraints:**
3333

@@ -56,7 +56,9 @@ class Solution {
5656
fun mergeKLists(lists: Array<ListNode>): ListNode? {
5757
return if (lists.isEmpty()) {
5858
null
59-
} else mergeKLists(lists, 0, lists.size)
59+
} else {
60+
mergeKLists(lists, 0, lists.size)
61+
}
6062
}
6163

6264
private fun mergeKLists(lists: Array<ListNode>, leftIndex: Int, rightIndex: Int): ListNode? {

0 commit comments

Comments
 (0)