public ArrayList<String> restoreIpAddresses2(String s) {
		// Start typing your Java solution below
		// DO NOT write main() function
		ArrayList<String> result = new ArrayList<String>();
		if (s.length() < 4 || s.length() > 16) {
			return result;
		}
		for (int i = 1; i <= s.length(); i++) {
			if (!isValid(s, 0, i)) {
				break;
			}

			for (int j = i + 1; j <= s.length(); j++) {
				if (!isValid(s, i, j)) {
					break;
				}

				for (int k = j + 1; k <= s.length(); k++) {

					if ((!isValid(s, j, k)) || (!isValid(s, k, s.length()))) {
						continue;
					}
					result.add(s.substring(0, i) + "." + s.substring(i, j)
							+ "." + s.substring(j, k) + "." + s.substring(k));

				}

			}
		}
		return result;

	}