private void helper(List<String> rst, StringBuffer sb, int leftRemain, int rightRemain) {

    if (leftRemain == 0 && rightRemain == 0) {
      rst.add(sb.toString());
    } else if (leftRemain < 0 || rightRemain < 0) {
      return;
    } else {
      if (leftRemain > 0) {
        sb.append("(");
        helper(rst, sb, leftRemain - 1, rightRemain);
        sb.delete(sb.length() - 1, sb.length());
      }

      if (rightRemain > leftRemain) {
        sb.append(")");
        helper(rst, sb, leftRemain, rightRemain - 1);
        sb.delete(sb.length() - 1, sb.length());
      }
    }
  }