MCPcopy Index your code
hub / github.com/doocs/leetcode / isIPv6

Method isIPv6

solution/0400-0499/0468.Validate IP Address/Solution.java:32–52  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

30 }
31
32 private boolean isIPv6(String s) {
33 if (s.endsWith(":")) {
34 return false;
35 }
36 String[] ss = s.split(":");
37 if (ss.length != 8) {
38 return false;
39 }
40 for (String t : ss) {
41 if (t.length() < 1 || t.length() > 4) {
42 return false;
43 }
44 for (char c : t.toCharArray()) {
45 if (!Character.isDigit(c)
46 && !"0123456789abcdefABCDEF".contains(String.valueOf(c))) {
47 return false;
48 }
49 }
50 }
51 return true;
52 }
53
54 private int convert(String s) {
55 int x = 0;

Callers 1

validIPAddressMethod · 0.95

Calls 3

lengthMethod · 0.80
valueOfMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected