public boolean isValid(String s) {
		if (s == null || s.isEmpty()) {
			return false;
		}
		Map<String, String> bracketsMap = new HashMap<String, String>();
		bracketsMap.put("(", ")");
		bracketsMap.put("{", "}");
		bracketsMap.put("[", "]");
		Stack<String> allBrackets = new Stack<String>();
		String curBracket = null;
		boolean isMath = false;
		for (int i = 0; i < s.length(); i++) {
			curBracket = s.substring(i, i + 1);
			if (bracketsMap.containsKey(curBracket)) {
				allBrackets.push(curBracket);
			} else {
				if (allBrackets.isEmpty()) {
					return false;
				}
				isMath = curBracket.equals(bracketsMap.get(allBrackets.pop()));
				if (!isMath) {
					return false;
				}
			}
		}
		if (allBrackets.size() != 0) {
			return false;
		} else {
			return true;
		}
	}