public static ArrayList<Integer> getRow(int rowIndex) {

		int length = rowIndex + 1;
		ArrayList<Integer> result = new ArrayList<Integer>(length);
		// initialization
		for (int i = 0; i < length; i++)
			result.add(0);
		// the first element of the array should be 1
		result.set(0, 1);
		// if (rowIndex == 0)
		// return result;
		for (int i = 1; i < rowIndex + 1; i++) {
			// the last element of the array should be 1
			result.set(i, 1);
			// add the element from the right to left
			// it won't affect the previous value of the array
			for (int j = i - 1; j >= 1; j--) {
				result.set(j, result.get(j) + result.get(j - 1));
			}
		}
		return result;
	}