About 18 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. 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.

  3. 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.

  4. C++ Program to Reverse a String Using Stack - GeeksforGeeks

    Dec 18, 2023 · Given a string, reverse it using stack. For example “GeeksQuiz” should be converted to “ziuQskeeG”. Following is simple algorithm to reverse a string using stack. 1) Create an empty stack. 2) One by one push all characters of string to stack. 3) One by one pop all characters from stack and put them back to string.

  5. 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.

  6. C Program To Reverse a String using Stack - Codeamy: Learn …

    Aug 1, 2019 · In this tutorial, String reverse using stack in this program. I implemented the stack push, pop function. Then, Put each character from string to stack, and as we known stack is working on LIFO. So, it removes the last element first using pop() and prints each character.

  7. 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.

  8. C program to Reverse a String using STACK

    Reversing string is an operation of Stack by using Stack we can reverse any string, here we implemented a program in C - this will reverse given string using Stack. Reverse a String using STACK. The logic behind to implement this program: Read a string. Push all characters until NULL is not found - Characters will be stored in stack variable.

  9. 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.

  10. Java reverse a string using stack - W3schools

    * @return */ public int peek {return stackArray [top];} /** * Returns true if the stack is empty * @return */ public boolean isStackEmpty {return (top ==-1);} /** * Returns true if the stack is full * @return */ public boolean isStackFull {return (top == stackSize -1);} public String reverseWord (String word) throws Exception {StringBuilder sb ...

  11. Some results have been removed