mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update dynamic_programming/word_break.cpp
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
parent
a3c9e701c3
commit
d8ab6b0282
@ -148,6 +148,24 @@ bool wordBreak(const std::string &s, const std::vector<std::string> &wordDict) {
|
||||
} // namespace word_break
|
||||
} // namespace dynamic_programming
|
||||
|
||||
/**
|
||||
* @brief Test implementations
|
||||
* @returns void
|
||||
*/
|
||||
static void test() {
|
||||
// the complete string
|
||||
const std::string s = "applepenapple";
|
||||
// the dictionary to be used
|
||||
const std::vector<std::string> wordDict = {"apple", "pen"};
|
||||
|
||||
assert(dynamic_programming::word_break::wordBreak(s, wordDict));
|
||||
|
||||
// should return true, as applepenapple can be segmented as apple + pen +
|
||||
// apple
|
||||
std::cout << dynamic_programming::word_break::wordBreak(s, wordDict)
|
||||
<< std::endl;
|
||||
std::cout << "Test implementation passed!\n";
|
||||
}
|
||||
/**
|
||||
* @brief Main function
|
||||
* @returns 0 on exit
|
||||
|
Loading…
Reference in New Issue
Block a user