From 039022becf5539ad852e0ef4b10cd4ef61469883 Mon Sep 17 00:00:00 2001 From: Anushka Verma Date: Mon, 24 Aug 2020 01:19:39 +0530 Subject: [PATCH 1/3] fix typo: (rename file) fast_interger_input -> fast_integer_input --- others/{fast_interger_input.cpp => fast_integer_input.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename others/{fast_interger_input.cpp => fast_integer_input.cpp} (100%) diff --git a/others/fast_interger_input.cpp b/others/fast_integer_input.cpp similarity index 100% rename from others/fast_interger_input.cpp rename to others/fast_integer_input.cpp From 7a13a35dfd6d4563d5dab7db3547b5e8f131fc61 Mon Sep 17 00:00:00 2001 From: Anushka Verma Date: Mon, 24 Aug 2020 01:47:16 +0530 Subject: [PATCH 2/3] feat: add word break solution (backtracking) --- backtracking/word_break.cpp | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 backtracking/word_break.cpp diff --git a/backtracking/word_break.cpp b/backtracking/word_break.cpp new file mode 100644 index 000000000..b41a6aa77 --- /dev/null +++ b/backtracking/word_break.cpp @@ -0,0 +1,50 @@ +/** + * @file Word Break + * + * @details + * Given a valid sentence without any spaces between the words and + * a dictionary of valid English words, find all possible ways to + * break the sentence in individual dictionary words. + * + * @author [Anushka Verma](https://github.com/verma-anushka) + */ + +#include +using namespace std; + +/** + * Utility function + */ +void wordbreak(string s, vector& dict, int i, string ans) { + + string word=s.substr(0, i+1); + int ws=s.size(); + + // search for word in the dictionary + if(find(dict.begin(), dict.end(), word) != dict.end()) { + + if(i dict = { "mobile","samsung","sam","sung", + "man","mango","icecream","and", + "go","i","like","ice","cream" }; + string s = "ilikesamsung"; + wordbreak(s, dict, 0, ""); + return 0; +} + From 47bbc2a16e28ed92aab5269fc390de3ee16e3b16 Mon Sep 17 00:00:00 2001 From: Anushka Verma Date: Mon, 24 Aug 2020 01:54:17 +0530 Subject: [PATCH 3/3] remove word break --- backtracking/word_break.cpp | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 backtracking/word_break.cpp diff --git a/backtracking/word_break.cpp b/backtracking/word_break.cpp deleted file mode 100644 index b41a6aa77..000000000 --- a/backtracking/word_break.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file Word Break - * - * @details - * Given a valid sentence without any spaces between the words and - * a dictionary of valid English words, find all possible ways to - * break the sentence in individual dictionary words. - * - * @author [Anushka Verma](https://github.com/verma-anushka) - */ - -#include -using namespace std; - -/** - * Utility function - */ -void wordbreak(string s, vector& dict, int i, string ans) { - - string word=s.substr(0, i+1); - int ws=s.size(); - - // search for word in the dictionary - if(find(dict.begin(), dict.end(), word) != dict.end()) { - - if(i dict = { "mobile","samsung","sam","sung", - "man","mango","icecream","and", - "go","i","like","ice","cream" }; - string s = "ilikesamsung"; - wordbreak(s, dict, 0, ""); - return 0; -} -