Skip to content

Commit 485a9e6

Browse files
refactor 468
1 parent a47c1ef commit 485a9e6

File tree

1 file changed

+0
-40
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-40
lines changed

src/main/java/com/fishercoder/solutions/_468.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,6 @@
44
import java.util.HashSet;
55
import java.util.Set;
66

7-
/**
8-
* 468. Validate IP Address
9-
*
10-
* Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.
11-
* IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers,
12-
* each ranging from 0 to 255, separated by dots ("."), e.g.,172.16.254.1;
13-
* Besides, leading zeros in the IPv4 is invalid. For example, the address 172.16.254.01 is invalid.
14-
15-
IPv6 addresses are represented as eight groups of four hexadecimal digits,
16-
each group representing 16 bits.
17-
The groups are separated by colons (":").
18-
For example, the address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is a valid one.
19-
Also, we could omit some leading zeros among four hexadecimal digits and
20-
some low-case characters in the address to upper-case ones,
21-
so 2001:db8:85a3:0:0:8A2E:0370:7334 is also a valid IPv6 address(Omit leading zeros and using upper cases).
22-
23-
However, we don't replace a consecutive group of zero value with a single empty
24-
group using two consecutive colons (::) to pursue simplicity.
25-
For example, 2001:0db8:85a3::8A2E:0370:7334 is an invalid IPv6 address.
26-
27-
Besides, extra leading zeros in the IPv6 is also invalid.
28-
For example, the address 02001:0db8:85a3:0000:0000:8a2e:0370:7334 is invalid.
29-
30-
Note: You may assume there is no extra space or special characters in the input string.
31-
32-
Example 1:
33-
Input: "172.16.254.1"
34-
Output: "IPv4"
35-
Explanation: This is a valid IPv4 address, return "IPv4".
36-
37-
Example 2:
38-
Input: "2001:0db8:85a3:0:0:8A2E:0370:7334"
39-
Output: "IPv6"
40-
Explanation: This is a valid IPv6 address, return "IPv6".
41-
42-
Example 3:
43-
Input: "256.256.256.256"
44-
Output: "Neither"
45-
Explanation: This is neither a IPv4 address nor a IPv6 address.
46-
validIPAddress */
477
public class _468 {
488

499
public static class Solution1 {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy