Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/leetcode/problems_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ var problemStatus = map[int]bool{
1046: true,
1047: true,
1051: true,
1108: true,
1154: true,
1163: true,
1185: true,
Expand Down
4 changes: 2 additions & 2 deletions problems/defanging-an-ip-address/defanging_an_ip_address.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package defanging_an_ip_address
package problem_1108

import "strings"

func defangIPaddr(address string) string {
return strings.Replace(address, ".", "[.]", -1)
return strings.ReplaceAll(address, ".", "[.]")
}
27 changes: 27 additions & 0 deletions problems/defanging-an-ip-address/defanging_an_ip_address_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package problem_1108

import "testing"

type caseType struct {
input string
expected string
}

func TestDefangIPaddr(t *testing.T) {
tests := [...]caseType{
{
input: "1.1.1.1",
expected: "1[.]1[.]1[.]1",
},
{
input: "255.100.50.0",
expected: "255[.]100[.]50[.]0",
},
}
for _, tc := range tests {
output := defangIPaddr(tc.input)
if output != tc.expected {
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
}
}
}