Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
binary search tree reversal
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace CodingAlgorithms { public static class ReverseWords { //Reverse words in a string public static string Reverse(string s) { string result = ""; Stack temp = new Stack(); s = s.Trim(); //Remove extra white space between characters while (s.Contains(" ")) s = s.Replace(" ", " "); //Store each word on the Stack foreach (string x in s.Split(' ')) temp.Push(x); //Add each word to the result string in reverse order since a stack is a FIFO data structure while (temp.Count != 0) result += temp.Pop() + " "; return result.Trim(); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
binary search find minimum
q1
hamming distance
jkb
Escape's Vanity Fair (Malformed \p {X} character escape)
Non-User input - Random Controlled - Guessing Game
from Base or Derived
The modifier 'private' is not valid for this item
ICollection<T>.Add(T) - Performance Test
Random Number Generation
Please log in to post a comment.