About 3,610,000 results
Open links in new tab
  1. Reverse a String using Stack - GeeksforGeeks

    Apr 4, 2025 · 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. Time Complexity: O (n) Only one traversal to push and one to pop so O (n)+O (n) = O (n).

  2. Java Program to Reverse a String using Stack - GeeksforGeeks

    Oct 21, 2020 · Given string str, the task is to write a Java program to swap the pairs of characters of a string. If the string contains an odd number of characters then the last character remains as it is. Examples: Input: str = “Java†Output: aJav Explanation: The given string contains even number of characters.

  3. Write a program to reverse a string using stack.

    Write a program to reverse a string using stack. stack.append(item) def pop(stack): if stack == []: return return stack.pop() def reverse(string): . n = len(string) . stack = [] for i in range(n): . push(stack, string[i]) . string = "" for i in range(n): . string += pop(stack) return string. print("Result=", output)

  4. Write a C Program To Reverse String using Stack - CodezClub

    Apr 11, 2017 · Write a C Program To Reverse String using Stack. Here’s simple Program To Reverse String using Stack in C Programming Language. Stack is an abstract data type with a bounded(predefined) capacity.

  5. Reverse a string using a stack data structure | Techie Delight

    Dec 1, 2021 · This post will discuss how to reverse a string using the stack data structure in C/C++, Java, and Python using explicit stack and call stack.

  6. Java Coding Challenge - Reverse a String using Stack - Java Guides

    In this blog post, we will discuss how to reverse a string using a stack in Java. We will walk through the implementation using a utility class Stacks, along with code snippets to illustrate each step. You are given a string, and your task is to reverse it using a stack.

  7. Java Program to Reverse a String Using Stack - Tpoint Tech

    Mar 17, 2025 · Approach to reverse a string using stack. Push the elements/characters of the string individually into the stack of datatype characters. Pop the elements/characters individually from the Stack until the stack becomes vacant. Add a popped component to the character array. Convert character array to string. Return turned around the string.

  8. Java Program to Reverse a String using Stack Data Structure

    Apr 16, 2022 · We can use the property of stack data structure to reverse a string. Here are the algorithm – First we have to push all the characters of a string in a stack.

  9. Reverse a String using Stack Data Structure - Java Guides

    In this article, we will discuss how to reverse a string using stack operations. This program uses stack operations to reverse a word (string). First, we push each character to the stack, then we will pop each char from the stack. public String reverseWord (String word) { StringBuilder stringBuilder = new StringBuilder ();

  10. Write a Java program to Reversing a String using a Stack

    The code demonstrates how to reverse a string using a stack in Java. Let's go through the code step by step: The code starts with the import statement import java.util.Stack; to import the Stack class from the java.util package. The StringReverse …

  11. Some results have been removed
Refresh