Repository: TheAlgorithms/C-Plus-Plus
File: backtracking/generate_parentheses.cpp (C++)

Code before:
/**
 * @file
 * @brief Generates all combinations of well-formed parentheses.
 * [Generate
 Parentheses](https://leetcode.com/explore/interview/card/top-interview-questions-medium/109/backtracking/794/)
 *
 * @details a sequence of parentheses is well-formed if each opening parentheses
 * has a corresponding closing parenthesis
 * and the closing parentheses are correctly ordered
 *
 * @author [Giuseppe Coco](https://github.com/WoWS17)

 */

#include <cassert>   /// for assert
#include <iostream>  /// for I/O operation
#include <vector>    /// for vector container

/**
 * @brief Backtracking algorithms
 * @namespace backtracking
 */
namespace backtracking {
/**
 * @brief generate_parentheses class
 * @namespace generate_parentheses
 */
class generate_parentheses {
 private:
    std::vector<std::string> res;  ///< Contains all possible valid patterns

    void makeStrings(std::string str, int n, int closed, int open);

 public:
    std::vector<std::string> generate(int n);
};
}  // namespace backtracking

/**
 * @brief function that implements backtracking
 *
 * @param str string build during backtracking
 * @param n number of pairs of parentheses
 * @param closed number of closed parentheses
 * @param open number of open parentheses
 */

void backtracking::generate_parentheses::makeStrings(std::string str, int n,
                                                     int closed, int open) {
    if (closed > open)  // We can never have more closed than open
        return;

Review comment (suggestion):
Please explain what the class is for, how it works, etc. briefly.
```suggestion
 * @brief generate_parentheses class
```


Code after:
/**
 * @file
 * @brief Well-formed [Generated
 * Parentheses](https://leetcode.com/explore/interview/card/top-interview-questions-medium/109/backtracking/794/) with all combinations.
 *
 * @details a sequence of parentheses is well-formed if each opening parentheses
 * has a corresponding closing parenthesis
 * and the closing parentheses are correctly ordered
 *
 * @author [Giuseppe Coco](https://github.com/WoWS17)

 */

#include <cassert>   /// for assert
#include <iostream>  /// for I/O operation
#include <vector>    /// for vector container

/**
 * @brief Backtracking algorithms
 * @namespace backtracking
 */
namespace backtracking {
/**
 * @brief generate_parentheses class
 */
class generate_parentheses {
 private:
    std::vector<std::string> res;  ///< Contains all possible valid patterns

    void makeStrings(std::string str, int n, int closed, int open);

 public:
    std::vector<std::string> generate(int n);
};

/**
 * @brief function that adds parenthesis to the string.
 *
 * @param str string build during backtracking
 * @param n number of pairs of parentheses
 * @param closed number of closed parentheses
 * @param open number of open parentheses
 */

void generate_parentheses::makeStrings(std::string str, int n,
                                                     int closed, int open) {
    if (closed > open)  // We can never have more closed than open
        return;

    if ((str.length() == 2 * n) &&
        (closed != open)) {  // closed and open must be the same