-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
word_break.rs in dynamic_programming #653
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you implement it using this Trie? https://github.com/TheAlgorithms/Rust/blob/da08798f02653dc5b5a02bce176a31d4c8ed9d42/src/data_structures/trie.rs
…present in data_structures
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #653 +/- ##
==========================================
+ Coverage 94.57% 94.65% +0.08%
==========================================
Files 285 290 +5
Lines 22906 23164 +258
==========================================
+ Hits 21664 21927 +263
+ Misses 1242 1237 -5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Word Break
Description
This implementation introduces the "Word Break" functionality, a feature that determines whether a given string can be segmented into a sequence of one or more words from a provided list. The solution uses a combination of Trie data structure and dynamic programming, offering efficient word lookup and optimal substructure for segmentation checks.
The algorithm involves building a Trie from the list of words, which allows for fast and efficient prefix searches. With the Trie, we can efficiently scan the string for available words starting from each position. Dynamic programming is then employed to remember and reuse the results of sub-problems, reducing redundant computations.
This method is particularly useful in natural language processing and word parsing scenarios, where such segmentation checks are frequent.
Type of change
Checklist:
cargo clippy --all -- -D warnings
just before my last commit and fixed any issue that was found.cargo fmt
just before my last commit.cargo test
just before my last commit and all tests passed.mod.rs
file within its own folder, and in any parent folder(s).DIRECTORY.md
with the correct link.COUNTRIBUTING.md
and my code follows its guidelines.