From b1333bcad6b83ec50b012743ee1e983d4be12011 Mon Sep 17 00:00:00 2001 From: katkat825 <137170306+katkat825@users.noreply.github.com> Date: Fri, 30 Jun 2023 12:51:21 -0400 Subject: [PATCH] add new file: c# reverse words in string --- algorithms/CSharp/README.md | 1 + algorithms/CSharp/src/Strings/reverse-words-in-string.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/algorithms/CSharp/README.md b/algorithms/CSharp/README.md index edee912a..9a9c43ed 100644 --- a/algorithms/CSharp/README.md +++ b/algorithms/CSharp/README.md @@ -30,6 +30,7 @@ To run the `.cs` file, kindly use [.Net Finddle](https://dotnetfiddle.net/) - [Palindrome](src/Strings/palindrome.cs) - [Trie](src/Strings/trie.cs) - [Character Limit](src/Strings/character-limit.cs) +- [Reverse Words in String](src/Strings/reverse-words-in-string.cs) ## Search diff --git a/algorithms/CSharp/src/Strings/reverse-words-in-string.cs b/algorithms/CSharp/src/Strings/reverse-words-in-string.cs index 2372ce30..8f8a5314 100644 --- a/algorithms/CSharp/src/Strings/reverse-words-in-string.cs +++ b/algorithms/CSharp/src/Strings/reverse-words-in-string.cs @@ -1,8 +1,6 @@ using System; -//Reverse the order of the words in a given string -//Example: "Hello World" becomes "World Hello" - +//Time Complexity: O(n) namespace Algorithms.Strings { public class ReverseWordsInString @@ -15,6 +13,8 @@ namespace Algorithms.Strings 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) { string[] words = input.Split(' ');