public int minimumTotal(ArrayList<ArrayList<Integer>> triangle) {
		int[] dp = new int[triangle.size()];
		dp[0] = triangle.get(0).get(0);
		for (int i = 1; i < triangle.size(); i++) {
			ArrayList<Integer> level = triangle.get(i);
			// last element of the current level
			dp[level.size() - 1] = dp[level.size() - 2]
					+ level.get(level.size() - 1);
			for (int j = level.size() - 2; j >= 1; j--) {
				dp[j] = Math
						.min(dp[j] + level.get(j), dp[j - 1] + level.get(j));
			}
			dp[0] = dp[0] + level.get(0);
		}
		int min = dp[0];
		for (int i : dp) {
			if (min > i)
				min = i;
		}
		return min;
	}