Skip to content

Add ReverseWordsInString #4456

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

Merged
merged 25 commits into from
Oct 6, 2023

Conversation

Suchiq
Copy link
Contributor

@Suchiq Suchiq commented Sep 30, 2023

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

…e space.

Input: s = "the sky is blue"
Output: "blue is sky the"
…e space.

Input: s = "the sky is blue"
Output: "blue is sky the"
@vil02 vil02 self-assigned this Oct 1, 2023
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

What if have some characters like \n or \t?

@Suchiq
Copy link
Contributor Author

Suchiq commented Oct 2, 2023

\n

added replace all to remove whitespace char from the string, please review

@vil02
Copy link
Member

vil02 commented Oct 2, 2023

\n

added replace all to remove whitespace char from the string, please review

Could you also add a test case when such operation occurs?

@Suchiq
Copy link
Contributor Author

Suchiq commented Oct 2, 2023

\n

added replace all to remove whitespace char from the string, please review

Could you also add a test case when such operation occurs?

done

@Suchiq Suchiq requested a review from vil02 October 2, 2023 14:22
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

Your code loop for ever. The start is always zero. Maybe your findNextWord method should return a Pair<Integer, Integer> where the fist entry is the start and the second the length of the word (or end - depends on you, with the end it is never clear is the end is inclusive or not). You could also have a method called extractWord taking such pair as an argument. (make sure to import org.apache.commons.lang3.tuple.Pair;).

In any case: always make sure that all of the CI checks pass.

@Suchiq Suchiq requested a review from vil02 October 3, 2023 15:48
@Suchiq
Copy link
Contributor Author

Suchiq commented Oct 3, 2023

Your code loop for ever. The start is always zero. Maybe your findNextWord method should return a Pair<Integer, Integer> where the fist entry is the start and the second the length of the word (or end - depends on you, with the end it is never clear is the end is inclusive or not). You could also have a method called extractWord taking such pair as an argument. (make sure to import org.apache.commons.lang3.tuple.Pair;).

In any case: always make sure that all of the CI checks pass.

Thanks yes fixed the issue, please check

@Suchiq Suchiq requested a review from vil02 October 5, 2023 11:31
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

We are almost there!

@vil02 vil02 changed the title Reverse word in the string Add ReverseWordsInString Oct 6, 2023
@vil02 vil02 merged commit 081f308 into TheAlgorithms:master Oct 6, 2023
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