<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stack string java - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/stack-string-java/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/stack-string-java/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 13 Sep 2021 07:26:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>stack string java - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/stack-string-java/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Write a program to reverse a string using stack data structure ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:18:34 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for palindrome using stack]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[data structure to reverse string ( other than stack)]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to push a string into a stack in c]]></category>
		<category><![CDATA[how to reverse a stack in c++]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[java input string]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[rereverse a string using stack in cstack string java]]></category>
		<category><![CDATA[reverse a linked list using stack in c]]></category>
		<category><![CDATA[reverse a list using stack in c]]></category>
		<category><![CDATA[reverse a number using stack]]></category>
		<category><![CDATA[reverse a number using stack in c]]></category>
		<category><![CDATA[reverse a string in java]]></category>
		<category><![CDATA[reverse a string using stack c++]]></category>
		<category><![CDATA[reverse a string using stack in c#]]></category>
		<category><![CDATA[reverse a string using stack in java]]></category>
		<category><![CDATA[reverse a string using stack in python]]></category>
		<category><![CDATA[reverse string using stack data structure in c]]></category>
		<category><![CDATA[reverse string using stack in java]]></category>
		<category><![CDATA[reverse words in a string using stack]]></category>
		<category><![CDATA[reverse words in a string using stack c++]]></category>
		<category><![CDATA[samsung interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[stack string java]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[use a stack to reverse the words of a sentence]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[WM Global Technology Services India Pvt.Ltd Limited (WMGTS) interview questions and answers]]></category>
		<category><![CDATA[write a program to reverse a string using stack data structu]]></category>
		<category><![CDATA[Xoriant Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Yodlee Infotech Pvt Ltd interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=478</guid>

					<description><![CDATA[Answer : Given a string, reverse it using stack...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="write-a-program-to-reverse-a-string-using-stack-data-structure" class="color-pink" style="text-align: justify;">Write a program to reverse a string using stack data structure ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Given a string, reverse it using stack. For example <a href="https://www.wikitechy.com/" target="_blank" rel="noopener">“Wikitechy”</a> should be converted to “yhcetikiW”.</li>
<li>Following is simple algorithm to reverse a string using stack.</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Empty stack to be created.</li>
<li><a href="https://www.wikitechy.com/tutorials/javascript/creating-multiline-string-in-javascript" target="_blank" rel="noopener">String</a> to stack put one by one push all characters.</li>
<li>From the stack and put them back to string one by one pop all characters.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/reserve-a-string-using-stack.jpg" alt=" Reserve a String Using Stack" /></div>
<div>
<h2 id="sample-code-in-java" class="color-purple" style="text-align: justify;">Sample Code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">import java.util.*; <br/>  <br/>//stack <br/>class Stack <br/>{ <br/>    int size; <br/>    int top; <br/>    char[] a;  <br/>  <br/>    //function to check if stack is empty <br/>    boolean isEmpty() <br/>    { <br/>        return (top &lt; 0); <br/>    } <br/>      <br/>    Stack(int n) <br/>    { <br/>        top = -1; <br/>        size = n; <br/>        a = new char[size]; <br/>    } <br/>  <br/>    //function to push element in Stack <br/>    boolean push(char x) <br/>    { <br/>        if (top &gt;= size) <br/>        { <br/>        System.out.println(&quot;Stack Overflow&quot;); <br/>        return false; <br/>        } <br/>        else<br/>        { <br/>            a[++top] = x; <br/>            return true; <br/>        } <br/>    } <br/>  <br/>    //function to pop element from stack <br/>    char pop() <br/>    { <br/>        if (top &lt; 0) <br/>        { <br/>        System.out.println(&quot;Stack Underflow&quot;); <br/>        return 0; <br/>        } <br/>        else<br/>        { <br/>            char x = a[top--]; <br/>            return x; <br/>        } <br/>    } <br/>} <br/>  <br/>  <br/>// Driver code <br/>class Main <br/>{ <br/>    //function to reverse the string <br/>    public static void reverse(StringBuffer str) <br/>    { <br/>        // Create a stack of capacity  <br/>        // equal to length of string <br/>        int n = str.length(); <br/>        Stack obj = new Stack(n); <br/>          <br/>        // Push all characters of string  <br/>        // to stack <br/>        int i; <br/>        for (i = 0; i &lt; n; i++) <br/>        obj.push(str.charAt(i)); <br/>      <br/>        // Pop all characters of string  <br/>        // and put them back to str <br/>        for (i = 0; i &lt; n; i++) <br/>        {  <br/>            char ch = obj.pop(); <br/>            str.setCharAt(i,ch); <br/>        } <br/>    }  <br/>      <br/>    //driver function <br/>    public static void main(String args[]) <br/>    { <br/>        //create a new string <br/>        StringBuffer s= new StringBuffer(&quot;Wikitechy&quot;); <br/>          <br/>        //call reverse method <br/>        reverse(s); <br/>          <br/>        //print the reversed string <br/>        System.out.println(&quot;Reversed string is &quot; + s); <br/>    } <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code id="code1" class="hljs typescript" data-lang=""><span class="nt">Reversed <span class="hljs-built_in">string</span> is yhcetikiW.
</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="time-complexity" class="color-blue">Time Complexity:</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">O(n) where n is number of characters in stack.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
