首页 > 其他分享 >LeetCode 22 -- Generate Parentheses

LeetCode 22 -- Generate Parentheses

时间:2023-02-11 20:34:00浏览次数:46  
标签:le 22 parentheses -- Generate Parentheses LeetCode

Problem

Given \(n\) pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Example 1

Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]

Example 2

Input: n = 1
Output: ["()"]

Constraints

  • \(1 \le n \le 8\)

Solution

标签:le,22,parentheses,--,Generate,Parentheses,LeetCode
From: https://www.cnblogs.com/Not-Even-Wrong/p/17112503.html

相关文章

  • python路径 目录 文件夹
    绝对路径1、os.path方法importosimportsyscurrent_directory=os.path.dirname(os.path.abspath(__file__))print(current_directory)2、os.path.abspath方法import......
  • 游戏类C程序设计
    1迷宫游戏1.1MAZE1.0#include<iostream>usingnamespacestd;intmain(){intx=1,y=2,mx=10,my=9;charch;cout<<"ready!\n";while(true)......
  • Literature分类的序
    Literature分类的序Datetime:2023-02-05T20:27:34+08:00Categories:LiteratureLocation:BeihangUniversity创建了一个分类,叫Literature。我尽量使用英文作为分......
  • GitLab CICD Day 17 - Image递增版本号 - 2
    新增build版本号variables:user:ericpwd:Admin@1234harbor:http://172.16.128.215:8080image_hellocat:172.16.128.215:8080/hive/hellocatstages:-testing......
  • C语言学习:案例:单链表的基本实现
     1#include<io_utils.h>2#include<stdlib.h>34typedefstructListNode{5intvalue;6structListNode*next;7}ListNode;89......
  • JDBC控制事务实现
    事务一个包含多个步骤的业务操作。如果这个业务操作被事务管理,则这多个步骤要么同时成功,要么同时失败。操作开启事务提交事务回滚事务使用Connection对象来管理事务......
  • 算法刷题-四数之和、缺失的第一个正数、N 皇后
    四数之和给定一个包含n个整数的数组nums和一个目标值target,判断nums中是否存在四个元素a,b,c和d,使得a+b+c+d的值与target相等?找出所有满足条件且不重复......
  • Stream流(JDK8)
    Stream流为JDK8新增特性,为数组、集合等批量数据提供了一套函数式操作方法,简化数组和集合操作的API。这个Stream的流不同于​​java.io​​的InputStream和OutputStream,它代......
  • GitLab CICD Day 19 - SSH免密登录远程服务器 *
    服务器免密:生成ssh-key(服务器A&B)[root@qaonpremise]#ssh-keygenGeneratingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rs......
  • (笔试题)经典题目
    题目代码一#include<stdio.h>#include<string.h>intmain(){chara[1000];inti;for(i=0;i<1000;i++){a[i]=-1-i;}printf("%d",strlen(a));return0;}分......