Repository: TheAlgorithms/C-Plus-Plus
File: dynamic_programming/palindrome_partitioning.cpp (C++)

Code before:
 * @brief palindrome partitioning algorithm gives you the minimum number of partitions you need to make
 * in order to divide a given string into a number of palindromes
 *
 * @details
 * palindrome partitioning uses dynamic programming and goes to all the possible partitions to find the minimum
 * you are given a string and you need to give minimum number of partitions needed to divide it into a number of palindromes
 * overall time complexity O(n^2)
 * For example: example 1:-
 * String : "nitik"
 * Output : 2 => "n | iti | k"
 * For example: example 2:-
 * String : "ababbbabbababa"
 * Output : 3 => "aba | b | bbabb | ababa"
 * @author [Sujay Kaushik] (https://github.com/sujaykaushik008)
 * @see related problem at [Leetcode] (https://leetcode.com/problems/palindrome-partitioning-ii/)
 */

#include <iostream>   // for io operations
#include <vector>     // for std::vector
#include <algorithm>  // for std::min
#include <cassert>    // for std::assert
#include <climits>    // for INT_MAX

/**
 * @namespace dynamic_programming
 * @brief dynamic programming algorithms
 */
namespace dynamic_programming {

    /**
     * @namespace palindrome_partitioning
     * @brief palindrome partitioning algorithms
     */
    namespace palindrome_partitioning {

        /**
         * Function implementing palindrome partitioning algorithm using lookup table method.
         * @param str input string
         * @returns minimum number of partitions
         */
        int pal_part(const std::string &str) {

            int n = str.size();

            // creating lookup table for minimum number of cuts
            std::vector<std::vector<int> > cuts(n, std::vector<int>(n, 0));

            // creating lookup table for palindrome checking
            std::vector<std::vector<bool> > is_palindrome(n, std::vector<bool>(n, false));

            // initialization

Review comment (suggestion):
```suggestion
 * @brief Dynamic Programming algorithms
```

Code after:
 * @brief Implements [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning-ii/) algorithm, giving you the minimum number of partitions you need to make
 *
 * @details
 * palindrome partitioning uses dynamic programming and goes to all the possible partitions to find the minimum
 * you are given a string and you need to give minimum number of partitions needed to divide it into a number of palindromes
 * [Palindrome Partitioning] (https://www.geeksforgeeks.org/palindrome-partitioning-dp-17/)
 * overall time complexity O(n^2)
 * For example: example 1:-
 * String : "nitik"
 * Output : 2 => "n | iti | k"
 * For example: example 2:-
 * String : "ababbbabbababa"
 * Output : 3 => "aba | b | bbabb | ababa"
 * @author [Sujay Kaushik] (https://github.com/sujaykaushik008)
 */

#include <iostream>   // for io operations
#include <vector>     // for std::vector
#include <algorithm>  // for std::min
#include <cassert>    // for std::assert
#include <climits>    // for INT_MAX

/**
 * @namespace dynamic_programming
 * @brief Dynamic Programming algorithms
 */
namespace dynamic_programming {

    /**
     * @namespace palindrome_partitioning
     * @brief Functions for [Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning-ii/) algorithm
     */
    namespace palindrome_partitioning {

        /**
         * Function implementing palindrome partitioning algorithm using lookup table method.
         * @param str input string
         * @returns minimum number of partitions
         */
        int pal_part(const std::string &str) {

            int n = str.size();

            // creating lookup table for minimum number of cuts
            std::vector<std::vector<int> > cuts(n, std::vector<int>(n, 0));

            // creating lookup table for palindrome checking
            std::vector<std::vector<bool> > is_palindrome(n, std::vector<bool>(n, false));

            // initialization
            for (int i = 0; i < n; i++) {