Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 23 paź 2008 · Starting with .NET Core 2.1 there is a new way to reverse a string using the string.Create method. Note that this solution does not handle Unicode combining characters etc. correctly, as "Les Mise\u0301rables" would be converted to "selbarésiM seL". See the other answers for a better solution.

  2. 23 mar 2023 · Follow the steps given below to reverse a string using stack. Create an empty stack. One by one push all characters of string to stack. One by one pop all characters from stack and put them back to string.

  3. 1 paź 2024 · Time Complexity: O(n) where n is length of string Auxiliary Space: O(n) Using Stack – O(n) Time and O(n) Space. The idea is to use stack for reversing a string because Stack follows Last In First Out (LIFO) principle. This means the last character you add is the first one you’ll take out.

  4. 2 lut 2012 · Pass the string to a char array, use Array.Reverse then pass the char array back as a string. Public static string ReverseString(string str) { char[] arr = str.ToCharArray(); Array.Reverse(arr); return new string(arr);}

  5. 4 mar 2006 · 2. Using a stack. This method is essentially the same as the first one, however it uses the FILO nature of the stack to accomplish the same task. publicstring Reverse (string s) { Stack<string> stack =new Stack<string> (); for (int i = 0; i < s.Length; i++) stack.Push (s.Substring (i, 1));

  6. 31 mar 2019 · This article explains different ways to reverse a String in C#. Here we explored the possible ways using both Iterative and Recursive methodologies without using Reverse method of .NET framework.

  7. 18 maj 2023 · Use Stack to Reverse a String. Next, we can use the Stack class, which is a last-in, first-out (LIFO) stack of objects, to reverse a string:

  1. Ludzie szukają również