Skip to content

Commit 52f6391

Browse files
committed
rename dir, fix validate-ip-address
1 parent 9e5d6c2 commit 52f6391

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed
File renamed without changes.
File renamed without changes.

src/validate-ip-address.go renamed to leetcode/validate-ip-address.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ func isValid4Item(segment string) (int, error) {
2424
}
2525

2626
func isValid6Item(item string) (uint64, error) {
27-
if len(item) > 4 || len(item) == 0 {
27+
length := len(item)
28+
if length > 4 || length == 0 {
2829
return 0, errors.New("invalid length")
2930
}
30-
if item[0] == '0' && len(item) > 1 {
31+
if item[0] == '0' && length != 4 && length > 1 {
3132
if item[1] == '0' {
32-
return 0, errors.New("invalid lead 0 ")
33+
return 0, errors.New("invalid lead 0")
3334
}
3435
}
3536

0 commit comments

Comments
 (0)