Skip to content

AdaGold/reverse-words

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reverse words

In this assignment, you'll design and implement one of the well-known string manipulation methods. Remember that a string is an array of characters. Algorithms that worked on restricted arrays will work on strings as well.

Exercise

  • Design and implement a method to reverse each word in a sentence in place. The sentence to reverse is passed in as the input parameter to the function. Design your algorithm to optimize the space complexity to be as minimal as possible.
  • For example, if the method is called with input parameter of "I can be an   engineer", the method should update the input string object to have the value "I nac eb na   reenigne".
    • Note that the count of white spaces between words is preserved.
  • Share and explain the time and space complexities for your solution in the comment above the method.
    • If the complexity is described in terms of n, your explanation must share what n stands for.

Notes: * Do not use Ruby provided functionality for .reverse and .reverse!. * You may use .length method provided in the String class.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages