Skip to content
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

Merged
merged 5 commits into from
Jan 10, 2024
Merged

word_break.rs in dynamic_programming #653

merged 5 commits into from
Jan 10, 2024

Conversation

tudor-cretu
Copy link
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I ran bellow commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked COUNTRIBUTING.md and my code follows its guidelines.

@tudor-cretu tudor-cretu marked this pull request as ready for review January 9, 2024 13:12
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cb3b21d) 94.57% compared to head (fde2909) 94.65%.
Report is 6 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit 0d8e86b into TheAlgorithms:master Jan 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants