Skip to content

Commit d94f6b6

Browse files
authored
Updated tasks 1-39
1 parent 2a1c52c commit d94f6b6

File tree

38 files changed

+83
-119
lines changed

38 files changed

+83
-119
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ You can return the answer in any order.
3535
* <code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code>
3636
* **Only one valid answer exists.**
3737

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

src/main/go/g0001_0100/s0001_two_sum/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package s0001_two_sum
33
// #Easy #Top_100_Liked_Questions #Top_Interview_Questions #Array #Hash_Table
44
// #Data_Structure_I_Day_2_Array #Level_1_Day_13_Hashmap #Udemy_Arrays #Top_Interview_150_Hashmap
55
// #Big_O_Time_O(n)_Space_O(n) #AI_can_be_used_to_solve_the_task
6-
// #2024_01_28_Time_3_ms_(93.85%)_Space_4.2_MB_(58.64%)
6+
// #2025_04_27_Time_0_ms_(100.00%)_Space_5.85_MB_(61.87%)
77

88
func twoSum(nums []int, target int) []int {
99
indexMap := make(map[int]int)

src/main/go/g0001_0100/s0002_add_two_numbers/solution.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package s0002_add_two_numbers
33
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Math #Linked_List #Recursion
44
// #Data_Structure_II_Day_10_Linked_List #Programming_Skills_II_Day_15
55
// #Top_Interview_150_Linked_List #Big_O_Time_O(max(N,M))_Space_O(max(N,M))
6-
// #AI_can_be_used_to_solve_the_task #2024_03_05_Time_4_ms_(84.60%)_Space_4.4_MB_(47.97%)
6+
// #AI_can_be_used_to_solve_the_task #2025_04_27_Time_0_ms_(100.00%)_Space_6.17_MB_(92.78%)
77

88
type ListNode struct {
99
Val int
@@ -21,7 +21,6 @@ func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
2121
dummyHead := &ListNode{}
2222
p, q, curr := l1, l2, dummyHead
2323
carry := 0
24-
2524
for p != nil || q != nil {
2625
x, y := 0, 0
2726
if p != nil {
@@ -32,16 +31,13 @@ func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
3231
y = q.Val
3332
q = q.Next
3433
}
35-
3634
sum := carry + x + y
3735
carry = sum / 10
3836
curr.Next = &ListNode{Val: sum % 10}
3937
curr = curr.Next
4038
}
41-
4239
if carry > 0 {
4340
curr.Next = &ListNode{Val: carry}
4441
}
45-
4642
return dummyHead.Next
4743
}

src/main/go/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Medium
44

5-
Given a string `s`, find the length of the **longest** **substring** without repeating characters.
5+
Given a string `s`, find the length of the **longest** **substring** without duplicate characters.
66

77
**Example 1:**
88

src/main/go/g0001_0100/s0003_longest_substring_without_repeating_characters/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package s0003_longest_substring_without_repeating_characters
33
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Hash_Table #Sliding_Window
44
// #Algorithm_I_Day_6_Sliding_Window #Level_2_Day_14_Sliding_Window/Two_Pointer #Udemy_Strings
55
// #Top_Interview_150_Sliding_Window #Big_O_Time_O(n)_Space_O(1) #AI_can_be_used_to_solve_the_task
6-
// #2024_03_05_Time_0_ms_(100.00%)_Space_2.5_MB_(98.66%)
6+
// #2025_04_27_Time_0_ms_(100.00%)_Space_4.45_MB_(94.51%)
77

88
func lengthOfLongestSubstring(s string) int {
99
lastIndices := make([]int, 256)

src/main/go/g0001_0100/s0004_median_of_two_sorted_arrays/solution.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@ package s0004_median_of_two_sorted_arrays
22

33
// #Hard #Top_100_Liked_Questions #Top_Interview_Questions #Array #Binary_Search #Divide_and_Conquer
44
// #Top_Interview_150_Binary_Search #Big_O_Time_O(log(min(N,M)))_Space_O(1)
5-
// #AI_can_be_used_to_solve_the_task #2024_03_05_Time_9_ms_(72.04%)_Space_4.8_MB_(67.69%)
5+
// #AI_can_be_used_to_solve_the_task #2025_04_27_Time_0_ms_(100.00%)_Space_6.51_MB_(81.58%)
66

77
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
88
if len(nums1) > len(nums2) {
99
nums1, nums2 = nums2, nums1
1010
}
11-
1211
x, y := len(nums1), len(nums2)
1312
low, high := 0, x
14-
1513
for low <= high {
1614
partitionX := (low + high) / 2
1715
partitionY := (x+y+1)/2 - partitionX
18-
1916
maxLeftX := getIntValue(nums1, partitionX-1)
2017
minRightX := getIntValue(nums1, partitionX)
21-
2218
maxLeftY := getIntValue(nums2, partitionY-1)
2319
minRightY := getIntValue(nums2, partitionY)
24-
2520
if maxLeftX <= minRightY && maxLeftY <= minRightX {
2621
if (x+y)%2 == 0 {
2722
return float64(max(maxLeftX, maxLeftY)+min(minRightX, minRightY)) / 2
@@ -34,7 +29,6 @@ func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
3429
low = partitionX + 1
3530
}
3631
}
37-
3832
return 0.0
3933
}
4034

src/main/go/g0001_0100/s0005_longest_palindromic_substring/solution.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package s0005_longest_palindromic_substring
33
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #String #Dynamic_Programming
44
// #Data_Structure_II_Day_9_String #Algorithm_II_Day_14_Dynamic_Programming
55
// #Dynamic_Programming_I_Day_17 #Udemy_Strings #Top_Interview_150_Multidimensional_DP
6-
// #Big_O_Time_O(n)_Space_O(n) #2024_03_05_Time_0_ms_(100.00%)_Space_3.8_MB_(32.56%)
6+
// #Big_O_Time_O(n)_Space_O(n) #2025_04_27_Time_0_ms_(100.00%)_Space_5.76_MB_(29.62%)
77

88
func longestPalindrome(s string) string {
99
newStr := make([]byte, len(s)*2+1)
@@ -15,7 +15,6 @@ func longestPalindrome(s string) string {
1515
dp := make([]int, len(newStr))
1616
friendCenter, friendRadius := 0, 0
1717
lpsCenter, lpsRadius := 0, 0
18-
1918
for i := 0; i < len(newStr); i++ {
2019
if friendCenter+friendRadius > i {
2120
dp[i] = min(dp[2*friendCenter-i], (friendCenter+friendRadius)-i)

src/main/go/g0001_0100/s0006_zigzag_conversion/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package s0006_zigzag_conversion
22

33
// #Medium #String #Top_Interview_150_Array/String
4-
// #2024_03_05_Time_0_ms_(100.00%)_Space_4_MB_(86.83%)
4+
// #2025_04_27_Time_0_ms_(100.00%)_Space_5.75_MB_(95.79%)
55

66
func convert(s string, numRows int) string {
77
topJump := (numRows-2)*2 + 2

src/main/go/g0001_0100/s0007_reverse_integer/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package s0007_reverse_integer
22

33
// #Medium #Top_Interview_Questions #Math #Udemy_Integers
4-
// #2024_03_07_Time_0_ms_(100.00%)_Space_2.2_MB_(46.99%)
4+
// #2025_04_27_Time_0_ms_(100.00%)_Space_4.03_MB_(24.37%)
55

66
import "math"
77

src/main/go/g0001_0100/s0008_string_to_integer_atoi/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package s0008_string_to_integer_atoi
22

3-
// #Medium #Top_Interview_Questions #String #2024_03_07_Time_0_ms_(100.00%)_Space_2.3_MB_(27.02%)
3+
// #Medium #Top_Interview_Questions #String #2025_04_27_Time_0_ms_(100.00%)_Space_4.07_MB_(99.22%)
44

55
import (
66
"math"

0 commit comments

Comments
 (0)