백트래킹14 [leetcode 22] Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. n개의 올바른 괄호로 구성된 문자열 만들기 Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["()"] 풀이: -백트래킹 문제 -비교적 쉬웠다. class Solution { public: vector answer; int N; void BackTracking(int front, int back, string tmp){ if(front == N && back == N){ a.. 2020. 10. 15. [leetcode 17] Letter Combinations of a Phone Number Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 전형적인 백트래킹 문제. 숫자에 해당하는 알파벳의 조합을 모두 찾기 Example 1: Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd","c.. 2020. 10. 14. 이전 1 2 3 4 다음