public int longestValidParentheses(String s) {
		f = new Boolean[s.length() + 1][];
		this.s = s;
		for (int i = 0; i <= s.length(); i++) {
			f[i] = new Boolean[s.length() + 1];
			for (int j = i + 2; j <= s.length(); j += 2) {
				f[i][j] = null;
			}
		}
		int rst = 0;
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) == ')')
				continue;
			int j = s.length();
			if ((j - i) % 2 == 1)
				j--;
			while (j - i > rst) {
				if (s.charAt(j-1) != '(') {
					search(i, j);
					if (f[i][j] == true) {
						rst = j - i;
						break;
					}
				}
				j -= 2;
			}
		}

		return rst;
	}