public void restoreIpAddressesHelper(String s, int index, StringBuilder sb,
			ArrayList<String> result, int counter) {
		// StringBuilder sbLocal = new StringBuilder();
		if (counter > 4) {// to speed up
			return;
		}
		if (index >= s.length()) {
			if (counter == 4) {
				sb.deleteCharAt(sb.length() - 1);// delete '.'
				result.add(sb.toString());
			}
			return;
		}
		if (index <= s.length() - 1) {
			if (isValidIPAddress(s.substring(index, index + 1))) {

				StringBuilder sbLocal = copySB(sb);

				sbLocal.append(s.substring(index, index + 1) + ".");
				restoreIpAddressesHelper(s, index + 1, sbLocal, result,
						counter + 1);
			} else {
				return;
			}
		}
		if (index <= s.length() - 2) {
			if (isValidIPAddress(s.substring(index, index + 2))) {

				StringBuilder sbLocal = copySB(sb);

				sbLocal.append(s.substring(index, index + 2) + ".");
				restoreIpAddressesHelper(s, index + 2, sbLocal, result,
						counter + 1);
			} else {
				return;
			}
		}
		if (index <= s.length() - 3) {
			if (isValidIPAddress(s.substring(index, index + 3))) {
				StringBuilder sbLocal = copySB(sb);
				sbLocal.append(s.substring(index, index + 3) + ".");
				restoreIpAddressesHelper(s, index + 3, sbLocal, result,
						counter + 1);
			} else {
				return;
			}
		}
		return;

	}