add new file: c# reverse words in string
parent
d1f7426a61
commit
b1333bcad6
|
@ -30,6 +30,7 @@ To run the `.cs` file, kindly use [.Net Finddle](https://dotnetfiddle.net/)
|
||||||
- [Palindrome](src/Strings/palindrome.cs)
|
- [Palindrome](src/Strings/palindrome.cs)
|
||||||
- [Trie](src/Strings/trie.cs)
|
- [Trie](src/Strings/trie.cs)
|
||||||
- [Character Limit](src/Strings/character-limit.cs)
|
- [Character Limit](src/Strings/character-limit.cs)
|
||||||
|
- [Reverse Words in String](src/Strings/reverse-words-in-string.cs)
|
||||||
|
|
||||||
## Search
|
## Search
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
//Reverse the order of the words in a given string
|
//Time Complexity: O(n)
|
||||||
//Example: "Hello World" becomes "World Hello"
|
|
||||||
|
|
||||||
namespace Algorithms.Strings
|
namespace Algorithms.Strings
|
||||||
{
|
{
|
||||||
public class ReverseWordsInString
|
public class ReverseWordsInString
|
||||||
|
@ -15,6 +13,8 @@ namespace Algorithms.Strings
|
||||||
Console.WriteLine(ReverseWords(originalString));
|
Console.WriteLine(ReverseWords(originalString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reverse the order of the words in a given string
|
||||||
|
//Example: "Hello World" becomes "World Hello"
|
||||||
public static string ReverseWords(string input)
|
public static string ReverseWords(string input)
|
||||||
{
|
{
|
||||||
string[] words = input.Split(' ');
|
string[] words = input.Split(' ');
|
||||||
|
|
Loading…
Reference in New Issue