<?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>samsung interview questions and answers - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/samsung-interview-questions-and-answers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/samsung-interview-questions-and-answers/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Thu, 16 Sep 2021 12:32:43 +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>samsung interview questions and answers - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/samsung-interview-questions-and-answers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Count number of bits to be flipped to convert A to B ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:48:41 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></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[bit flipping game code]]></category>
		<category><![CDATA[bit manipulation in c]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[brian kernighan’s algorithm]]></category>
		<category><![CDATA[c program to count number of ones and zeros]]></category>
		<category><![CDATA[c program to toggle a bit]]></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[count number of 1s in a binary number java]]></category>
		<category><![CDATA[count set bits]]></category>
		<category><![CDATA[count set bits in a number c++]]></category>
		<category><![CDATA[count total set bits in all numbers from 1 to n]]></category>
		<category><![CDATA[counting bits]]></category>
		<category><![CDATA[counting bits set by lookup table]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[flip all bits in c]]></category>
		<category><![CDATA[flip bits]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[flipped mountain code in c]]></category>
		<category><![CDATA[flipped mountain code in java]]></category>
		<category><![CDATA[flipped mountain in c]]></category>
		<category><![CDATA[flipped mountain pattern program in java]]></category>
		<category><![CDATA[flipped mountain program in c]]></category>
		<category><![CDATA[flipped mountain program in java]]></category>
		<category><![CDATA[flipped mountain program in python]]></category>
		<category><![CDATA[flipping bits in c]]></category>
		<category><![CDATA[flipping bits in java]]></category>
		<category><![CDATA[flipping bits program in c]]></category>
		<category><![CDATA[flipping bits solution]]></category>
		<category><![CDATA[flipping bits solution in c]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to count number of 1's in binary representation in c]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></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[reverse bytes in 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[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[toggle all bits in c]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></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[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=513</guid>

					<description><![CDATA[Answer : Write the program to count number of bits needed to be flipped...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b" class="color-pink" style="text-align: justify;">How to Count number of bits to be flipped to convert A to B ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Write the program to count number of bits needed to be flipped to convert ‘a’ to ‘b’. For Example given two numbers a = 6 and b = 12; then the output is 2
<ul>
<li><a href="https://www.wikitechy.com/technology/check-binary-representation-number-palindrome/" target="_blank" rel="noopener">Binary representation</a> of a is 00000<b>11</b>0</li>
<li>Binary representation of b is 00001100</li>
<li>We need to flip highlighted two bits in a</li>
<li>To make it b.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="explanation" class="color-purple">Explanation</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Calculate XOR of A and B.</li>
</ul>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">a_xor_b = A ^ B</span></code></pre>
</figure>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Count the set bits in the above Calculated XOR result.</li>
</ul>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs scss" data-lang=""><span class="nt"><span class="hljs-function">CountSetBits</span>(a_xor_b)</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-c" class="color-purple" style="text-align: justify;">Sample Code in C#</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">/ Count number of bits to be <br/>// flipped to convert A into B <br/>using System; <br/><br/>public class Count { <br/>	<br/>	// Function that count set bits <br/>	public static int countSetBits(int n) <br/>	{ <br/>		int count = 0; <br/>		while (n != 0) { <br/>			count += n &amp; 1; <br/>			n &gt;&gt;= 1; <br/>		} <br/>		return count; <br/>	} <br/><br/>	// Function that return <br/>	// count of flipped number <br/>	public static int FlippedCount(int a, int b) <br/>	{ <br/>	// Return count of set <br/>	// bits in a XOR b <br/>		return countSetBits(a ^ b); <br/>	} <br/>	<br/>	// Driver code <br/>	public static void Main() <br/>	{ <br/>		int a = 17; <br/>		int b = 55; <br/>		Console.WriteLine(FlippedCount(a, b)); <br/>	} <br/>} <br/><br/>// This code is contributed by vt_m. </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs" data-lang=""><span class="nt">3</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are the Minimum Initial Points to Reach Destination ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:44:33 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></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[bottom and up moves allowed]]></category>
		<category><![CDATA[bottom moves allowed]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find minimum moves to reach target on an infinite line]]></category>
		<category><![CDATA[find shortest path in 2d array in c]]></category>
		<category><![CDATA[find shortest path in matrix python]]></category>
		<category><![CDATA[find the minimum number of moves needed to move from one cell of matrix to another]]></category>
		<category><![CDATA[Flipkart 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[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[maximum cost path dynamic programm]]></category>
		<category><![CDATA[min cost flow]]></category>
		<category><![CDATA[minimum cost path]]></category>
		<category><![CDATA[minimum cost path dijkstra]]></category>
		<category><![CDATA[minimum cost path graph]]></category>
		<category><![CDATA[minimum cost path matrix java]]></category>
		<category><![CDATA[minimum cost path with left]]></category>
		<category><![CDATA[minimum cost path with right]]></category>
		<category><![CDATA[minimum number of jumps to reach end in java]]></category>
		<category><![CDATA[minimum number of jumps to reach end python]]></category>
		<category><![CDATA[minimum number of steps to reach a given number]]></category>
		<category><![CDATA[minimum steps to one dynamic programming]]></category>
		<category><![CDATA[minimum steps to reach a destination java]]></category>
		<category><![CDATA[minimum sum descent dynamic programming]]></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[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[shortest distance between two cells in a matrix or grid java]]></category>
		<category><![CDATA[shortest path between two points in a grid java]]></category>
		<category><![CDATA[shortest path from source to destination in matrix java]]></category>
		<category><![CDATA[shortest path in grid with obstacles]]></category>
		<category><![CDATA[shortest path in grid with obstacles python]]></category>
		<category><![CDATA[shortest path in matrix]]></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[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[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=511</guid>

					<description><![CDATA[Answer : To begin from the upper left corner of a given framework...]]></description>
										<content:encoded><![CDATA[<div>
<div class="hddn">
<h2 id="what-are-the-minimum-initial-points-to-reach-destination" class="color-pink" style="text-align: justify;">What are the Minimum Initial Points to Reach Destination ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To begin from the upper left corner of a given framework, one needs to achieve the base right corner.</li>
<li>Every cell in the grid contains a number, the number may positive or negative.</li>
<li>We can move across a cell only if we have positive points ( &gt; 0 ). Whenever we pass through a cell, points in that cell are added to our overall points.</li>
<li>We need to find minimum initial points to reach cell (m-1, n-1) from (0, 0) by following these certain set of rules :</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>From a cell (i, j) we can move to (i+1, j) or (i, j+1).</li>
<li>We cannot move from (i, j) if your overall points at (i, j) is &lt;= 0.</li>
<li>We have to reach at (n-1, m-1) with minimum positive points i.e., &gt; 0.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="syntax" class="color-purple">Syntax</h2>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs scss" data-lang=""><span class="nt"><span class="hljs-function">minInitTokens</span>(matrix) </span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-c" class="color-purple" style="text-align: justify;">Sample Code in C++</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include&lt;iostream&gt;<br/>#include&lt;cmath&gt;<br/>#define ROW 3<br/>#define COL 3<br/>using namespace std;<br/><br/>int tokens[ROW][COL] = {<br/>   {-2,-3,3},<br/>   {-5,-10,1},<br/>   {10,30,-5}<br/>};<br/><br/>int max(int a, int b) {<br/>   return (a&gt;b)?a:b;<br/>}<br/><br/>int minInitPoints() {<br/>   int minToken[ROW][COL];<br/>   int m = ROW, n = COL;<br/>   <br/>   minToken[m-1][n-1] = tokens[m-1][n-1] &gt; 0? 1: abs(tokens[m-1][n-1]) + 1;<br/>   <br/>   for (int i = m-2; i &gt;= 0; i--)    //from last row to first row, fill points<br/>      minToken[i][n-1] = max(minToken[i+1][n-1] - tokens[i][n-1], 1);<br/>   <br/>   for (int j = n-2; j &gt;= 0; j--)    //fill last column to first column, fill points<br/>      minToken[m-1][j] = max(minToken[m-1][j+1] - tokens[m-1][j], 1);<br/><br/>   for (int i=m-2; i&gt;=0; i--) {<br/>      for (int j=n-2; j&gt;=0; j--) {<br/>         int remPoint = min(minToken[i+1][j], minToken[i][j+1]);    //calculate remaining points<br/>         minToken[i][j] = max(remPoint - tokens[i][j], 1);<br/>      }<br/>   }<br/>   return minToken[0][0];<br/>}<br/><br/>int main() {<br/>   cout &lt;&lt; &quot;Least Points Required: &quot; &lt;&lt; minInitPoints();<br/>}</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs" data-lang=""><span class="nt">Least Points Required: 7</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Delete all occurrences of a given key in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:39:53 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></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[c program to delete first node in linked list]]></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[delete a specific node in linked list java]]></category>
		<category><![CDATA[delete all nodes in doubly linked list c++]]></category>
		<category><![CDATA[delete at position in a doubly linked list]]></category>
		<category><![CDATA[delete first node in linked list c++]]></category>
		<category><![CDATA[delete last node in doubly linked list in c++]]></category>
		<category><![CDATA[delete last node in linked list c++]]></category>
		<category><![CDATA[delete last node in linked list in c]]></category>
		<category><![CDATA[delete node at given position in a linked list in c++]]></category>
		<category><![CDATA[delete node from doubly linked list java]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list geeksforgeeks]]></category>
		<category><![CDATA[Flipkart 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[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></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[remove element from doubly linked list 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[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[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 delete a node from linked list in c++]]></category>
		<category><![CDATA[write ac program to delete a particular element in the doubly linked list]]></category>
		<category><![CDATA[write an algorithm to delete duplicate elements in a singly linked list]]></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=509</guid>

					<description><![CDATA[Answer : Given a singly linked list, delete all occurrences...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="delete-all-occurrences-of-a-given-key-in-a-linked-list" class="color-pink">Delete all occurrences of a given key in a linked list ?</h2>
</div>
</div>
<div class="CodeContent">
<div class="hddn">
<ul>
<li>Given a singly linked list, delete all occurrences of a given key in it. For example,</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Input:  2 -&gt; 1 -&gt; 8 -&gt; 2 -&gt;  3 -&gt;  2 -&gt; 7<br/>       Key to delete = 2<br/>Output:  1 -&gt; 8 -&gt; 3 -&gt; 7 </code></pre> </div>
<h2 id="sample-code-in-c" class="color-purple">Sample Code in C</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">#include &lt;stdio.h&gt; <br/>#include &lt;stdlib.h&gt; <br/>// A linked list node <br/>struct Node <br/>{ <br/>    int data; <br/>    struct Node *next; <br/>}; <br/>/* Given a reference (pointer to pointer) to the head of a list <br/>   and an int, inserts a new node on the front of the list. */<br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>    struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); <br/>    new_node-&gt;data  = new_data; <br/>    new_node-&gt;next = (*head_ref); <br/>    (*head_ref)    = new_node; <br/>} <br/>/* Given a reference (pointer to pointer) to the head of a list and <br/>   a key, deletes all occurrence of the given key in linked list */<br/>void deleteKey(struct Node **head_ref, int key) <br/>{ <br/>    // Store head node <br/>    struct Node* temp = *head_ref, *prev; <br/>    // If head node itself holds the key or multiple occurrences of key <br/>    while (temp != NULL &amp;&amp; temp-&gt;data == key) <br/>    { <br/>        *head_ref = temp-&gt;next;   // Changed head <br/>        free(temp);               // free old head <br/>        temp = *head_ref;         // Change Temp <br/>    } <br/>    // Delete occurrences other than head <br/>    while (temp != NULL) <br/>    { <br/>        // Search for the key to be deleted, keep track of the <br/>        // previous node as we need to change &#039;prev-&gt;next&#039; <br/>        while (temp != NULL &amp;&amp; temp-&gt;data != key) <br/>        { <br/>            prev = temp; <br/>            temp = temp-&gt;next; <br/>        } <br/>        // If key was not present in linked list <br/>        if (temp == NULL) return; <br/>        // Unlink the node from linked list <br/>        prev-&gt;next = temp-&gt;next; <br/>        free(temp);  // Free memory <br/>        //Update Temp for next iteration of outer loop <br/>        temp = prev-&gt;next; <br/>    } <br/>} <br/>// This function prints contents of linked list starting from <br/>// the given node <br/>void printList(struct Node *node) <br/>{ <br/>    while (node != NULL) <br/>    { <br/>        printf(&quot; %d &quot;, node-&gt;data); <br/>        node = node-&gt;next; <br/>    } <br/>} <br/>   /* Drier program to test above functions*/<br/>int main() <br/>{ <br/>    /* Start with the empty list */<br/>    struct Node* head = NULL; <br/>    push(&amp;head, 7); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 3); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 8); <br/>    push(&amp;head, 1); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 2); <br/>    int key = 2; // key to delete <br/>    puts(&quot;Created Linked List: &quot;); <br/>    printList(head); <br/>    deleteKey(&amp;head, key); <br/>    puts(&quot;\nLinked List after Deletion: &quot;); <br/>    printList(head); <br/>    return 0; <br/>}</code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">Created Linked List:
 2  2  1  8  2  3  2  7
Linked List after Deletion:
 1  8  3  7 </span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>
		<item>
		<title>Detect loop in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/detect-loop-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/detect-loop-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:08:43 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find length of linked list java]]></category>
		<category><![CDATA[find length of loop in linked list]]></category>
		<category><![CDATA[find length of loop in linked list in java]]></category>
		<category><![CDATA[find start of loop in linked list]]></category>
		<category><![CDATA[find start of loop in linked list java]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[floyd's cycle detection algorithm]]></category>
		<category><![CDATA[for loop linked list c++]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[java detect]]></category>
		<category><![CDATA[length of loop in linked list]]></category>
		<category><![CDATA[length of loop in linked list java]]></category>
		<category><![CDATA[linked list algorithm]]></category>
		<category><![CDATA[linked list in data structure]]></category>
		<category><![CDATA[linked list program in c with explanation]]></category>
		<category><![CDATA[linked list program in clinked list algorithm]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[n'th node from end of linked list]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[reverse a linked list]]></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[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[telibrahma 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[what is loop]]></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[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=473</guid>

					<description><![CDATA[Answer : There are two ways to detect loop in linked list...
]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="detect-loop-in-a-linked-list" class="color-pink">Detect loop in a linked list ?</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>There are two ways to detect loop in linked list or not.</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/detect-loop-in-a-linked-list.png" alt=" Detect Loop in a Linked List" /></div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="method-1" class="color-blue">Method 1:</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>Traverse through each node till end , tracking visited node using Hash map.</li>
<li>If you find node that is already visited, then there is a loop in LinkedList</li>
<li>If you reach till end while traversing then there is no loop in LinkedList</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">using namespace std; <br/><br/>struct Node <br/>{ <br/>	int data; <br/>	struct Node* next; <br/>}; <br/><br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/><br/>	struct Node* new_node = new Node; <br/><br/>	<br/>	new_node-&gt;data = new_data; <br/><br/>	/* link the old list off the new node */<br/>	new_node-&gt;next = (*head_ref); <br/><br/>	/* move the head to point to the new node */<br/>	(*head_ref) = new_node; <br/>} <br/><br/>// Returns true if there is a loop in linked list <br/>// else returns false. <br/>bool detectLoop(struct Node *h) <br/>{ <br/>	unordered_set&lt;Node *&gt; s; <br/>	while (h != NULL) <br/>	{ <br/>		// If this node is already present <br/>		// in hashmap it means there is a cycle <br/>		// (Because you we encountering the <br/>		// node for the second time). <br/>		if (s.find(h) != s.end()) <br/>			return true; <br/><br/>		// If we are seeing the node for <br/>		// the first time, insert it in hash <br/>		s.insert(h); <br/><br/>		h = h-&gt;next; <br/>	} <br/><br/>	return false; <br/>} <br/><br/>/* Drier program to test above function*/<br/>int main() <br/>{ <br/>	/* Start with the empty list */<br/>	struct Node* head = NULL; <br/><br/>	push(&amp;head, 21); <br/>	push(&amp;head, 14); <br/>	push(&amp;head, 5); <br/>	push(&amp;head, 10); <br/><br/>	/* Create a loop for testing */<br/>	head-&gt;next-&gt;next-&gt;next-&gt;next = head; <br/><br/>	if (detectLoop(head)) <br/>		cout &lt;&lt; &quot;Loop found&quot;; <br/>	else<br/>		cout &lt;&lt; &quot;No Loop&quot;; <br/><br/>	return 0; <br/>} </code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output" class="color-blue">Output:</h2>
<p><code class="hljs" data-lang=""><span class="nt">Loop found</span></code></p>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="method-2" class="color-blue">Method 2:</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>Efficient approach for this problem would be Floyd’s cycle detection algorithm, so steps for this algorithm would be:</li>
</ul>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Use two pointer fastPtr and slowPtr and initialize both to head of linkedlist</li>
<li>Move fastPtr by two nodes and slowPtr by one node in each iteration.</li>
<li>If fastPtr and slowPtr meet at some iteration , then there is a loop in linkedlist.</li>
<li>If fastPtr reaches to the end of linkedlist without meeting slow pointer then there is no loop in linkedlist (i.e fastPtr-&gt;next or fastPtr-&gt;next-&gt;next become null).</li>
</ul>
</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">// C program to detect loop in a linked list <br/>#include&lt;stdio.h&gt; <br/>#include&lt;stdlib.h&gt; <br/>/* Link list node */<br/>struct Node <br/>{ <br/>	int data; <br/>	struct Node* next; <br/>}; <br/><br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>	/* allocate node */<br/>	struct Node* new_node = <br/>		(struct Node*) malloc(sizeof(struct Node)); <br/><br/>	/* put in the data */<br/>	new_node-&gt;data = new_data; <br/><br/>	/* link the old list off the new node */<br/>	new_node-&gt;next = (*head_ref); <br/><br/>	/* move the head to point to the new node */<br/>	(*head_ref) = new_node; <br/>} <br/><br/>int detectloop(struct Node *list) <br/>{ <br/>	struct Node *slow_p = list, *fast_p = list; <br/><br/>	while (slow_p &amp;&amp; fast_p &amp;&amp; fast_p-&gt;next ) <br/>	{ <br/>		slow_p = slow_p-&gt;next; <br/>		fast_p = fast_p-&gt;next-&gt;next; <br/>		if (slow_p == fast_p) <br/>		{ <br/>		printf(&quot;Found Loop&quot;); <br/>		return 1; <br/>		} <br/>	} <br/>	return 0; <br/>} <br/><br/>/* Drier program to test above function*/<br/>int main() <br/>{ <br/>	/* Start with the empty list */<br/>	struct Node* head = NULL; <br/><br/>	push(&amp;head, 10); <br/>	push(&amp;head, 4); <br/>	push(&amp;head, 5); <br/>	push(&amp;head, 10); <br/><br/>	/* Create a loop for testing */<br/>	head-&gt;next-&gt;next-&gt;next-&gt;next = head; <br/>	detectloop(head); <br/><br/>	return 0; <br/>}</code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output-2" class="color-blue">Output:</h2>
</div>
</div>
<div class="CodeContent">
<div class="hddn">
<figure class="highlight">
<pre><code id="code2" class="hljs" data-lang=""><span class="nt">Found Loop</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/detect-loop-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
