public void calculateLongestLength(String s, String t, int[][] matrix) {
		for (int i = 0; i < s.length(); i++) {
			for (int j = 0; j < t.length(); j++) {
				if (s.charAt(i) == t.charAt(j)) {// if match, try to find the
													// previous one(diagonal
													// direction)
					if (i == 0 || j == 0) {
						matrix[i][j] = 1;
					} else {
						matrix[i][j] = matrix[i - 1][j - 1] + 1;
					}
				} else {// if not match, try to search the top and left
						// directions
					if (i == 0 || j == 0) {
						matrix[i][j] = 0;
					} else {
						matrix[i][j] = Math.max(matrix[i - 1][j],
								matrix[i][j - 1]);
					}
				}

			}
		}
	}