public int solve() {
		int wordLength = myCombinations[0].length();
		// if myLength is even less than wordLength, return 0 (impossible)
		if (myLength < wordLength)
			return 0;
		preprocess();
		// rolling array
		int currentBeadLength = wordLength; // length for dp1
		int[] dp1 = new int[myCombinations.length];
		int[] dp2 = new int[myCombinations.length];
		// initialize
		Arrays.fill(dp1, 1);
		while (currentBeadLength < myLength) {
			for (int i = 0; i < myCombinations.length; i++)
				for (Integer index: myLinks.get(i)) {
					dp2[index] += dp1[i];
				}
			currentBeadLength++;
			dp1 = dp2;
			dp2 = new int[myCombinations.length];
			Arrays.fill(dp2, 0);
		}
		int sum = 0;
		for (int i = 0; i < dp1.length; i++)
			sum += dp1[i];
		return sum;
	}