TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implements Palindrome Partitioning algorithm, giving you the minimum number of partitions you need to make. More...
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | dynamic_programming |
Dynamic Programming algorithms. | |
namespace | palindrome_partitioning |
Functions for Palindrome Partitioning algorithm. | |
Functions | |
int | dynamic_programming::palindrome_partitioning::pal_part (const std::string &str) |
static void | test () |
Test Function. | |
int | main () |
Main function. | |
Implements Palindrome Partitioning algorithm, giving you the minimum number of partitions you need to make.
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"
Definition in file palindrome_partitioning.cpp.
int main | ( | void | ) |
Main function.
Definition at line 128 of file palindrome_partitioning.cpp.
int dynamic_programming::palindrome_partitioning::pal_part | ( | const std::string & | str | ) |
Function implementing palindrome partitioning algorithm using lookup table method.
str | input string |
Definition at line 45 of file palindrome_partitioning.cpp.
|
static |
Test Function.
Definition at line 98 of file palindrome_partitioning.cpp.