zoukankan      html  css  js  c++  java
  • [leetcode]Generate Parentheses

    class Solution {
    public:
        int tot;
        vector<string> ans;
        void search(string p , int left , int right){
            if(left > tot || right > tot) return;
            if(left == tot && right == tot){
                ans.push_back(p);
                return;
            }
            if(left < right) return;
            search(p + "(" , left + 1 , right);
            search(p + ")" , left , right + 1);
        }
    
        vector<string> generateParenthesis(int n) {
            // Note: The Solution object is instantiated only once and is reused by each test case.
            tot = n;
            ans.clear();
            search("(" , 1 , 0);
            return ans;
        }
    };
  • 相关阅读:
    弹性布局、动画、过渡
    HTML
    数据库对象
    函数
    oracle与PL/SQL安装
    网络编程
    多线程
    联调接口
    vue 全局变量
    vue ajax请求
  • 原文地址:https://www.cnblogs.com/x1957/p/3414056.html
Copyright © 2011-2022 走看看