<?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>how to count occurrence of a given character in a string in c - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/how-to-count-occurrence-of-a-given-character-in-a-string-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/how-to-count-occurrence-of-a-given-character-in-a-string-in-c/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Sat, 11 Sep 2021 10:48:36 +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>how to count occurrence of a given character in a string in c - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/how-to-count-occurrence-of-a-given-character-in-a-string-in-c/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Find number of occurrence of each of the unique characters in a string ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 14 Jul 2021 00:03:09 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Atos 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[charat java]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[compro technologies interview questions and answers]]></category>
		<category><![CDATA[count occurrences of character in string java using hashmap]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[FIS Global Business Solutions India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[how to count characters in string array in java]]></category>
		<category><![CDATA[how to count occurrence of a given character in a string in c]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[java counter]]></category>
		<category><![CDATA[java replace]]></category>
		<category><![CDATA[java string]]></category>
		<category><![CDATA[java string compare]]></category>
		<category><![CDATA[java string contains]]></category>
		<category><![CDATA[java string length]]></category>
		<category><![CDATA[java string replace]]></category>
		<category><![CDATA[java trim]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[occurrence of each character in string java]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[program to find occurrence of a character in a string in java]]></category>
		<category><![CDATA[RBS India De interview questions and answers]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[string class in java]]></category>
		<category><![CDATA[string class methods in java]]></category>
		<category><![CDATA[string count]]></category>
		<category><![CDATA[substring java]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=664</guid>

					<description><![CDATA[Answer : In this program an approach using Hashmap....]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string" class="color-pink" style="text-align: justify;">Find number of occurrence of each of the unique characters in a string ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In this program an approach using <a href="https://www.wikitechy.com/tutorials/java/java-linked-hashmap" target="_blank" rel="noopener">Hashmap</a> in Java.
<ul>
<li>Declare a Hashmap in Java of {char, int}.</li>
<li>Traverse in the string, check if the Hashmap already contains the traversed character or not.</li>
<li>If it is present, then increase its count using <a href="https://www.wikitechy.com/tutorials/python/get-method-for-dictionaries-in-python" target="_blank" rel="noopener">get()</a> and put() function in Hashmap.</li>
<li>Once the traversal is completed, traverse in the Hashmap and print the character and its frequency.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="example" class="color-purple">Example</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">Input: str = &quot;Wikitechy&quot;<br/>Output: <br/>        W 1<br/>        i 2<br/>        k 1<br/>        t 1<br/>        e 1<br/>        c 1<br/>        h 1<br/>        y 1</code></pre> </div>
<h2 id="sample-code-in-java" class="color-blue">Sample Code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">// Java prorgam to count frequencies of <br/>// characters in string using Hashmap <br/>import java.io.*; <br/>import java.util.*; <br/>class OccurenceOfCharInString { <br/>	static void characterCount(String inputString) <br/>	{ <br/>		// Creating a HashMap containing char <br/>		// as a key and occurrences as a value <br/>		HashMap&lt;Character, Integer&gt; charCountMap = new HashMap&lt;Character, Integer&gt;(); <br/><br/>		// Converting given string to char array <br/><br/>		char[] strArray = inputString.toCharArray(); <br/><br/>		// checking each char of strArray <br/>		for (char c : strArray) { <br/>			if (charCountMap.containsKey(c)) { <br/><br/>				// If char is present in charCountMap, <br/>				// incrementing it&#039;s count by 1 <br/>				charCountMap.put(c, charCountMap.get(c) + 1); <br/>			} <br/>			else { <br/><br/>				// If char is not present in charCountMap, <br/>				// putting this char to charCountMap with 1 as it&#039;s value <br/>				charCountMap.put(c, 1); <br/>			} <br/>		} <br/><br/>		// Printing the charCountMap <br/>		for (Map.Entry entry : charCountMap.entrySet()) { <br/>			System.out.println(entry.getKey() + &quot; &quot; + entry.getValue()); <br/>		} <br/>	} <br/><br/>	// Driver Code <br/>	public static void main(String[] args) <br/>	{ <br/>		String str = &quot;Wikitechy&quot;; <br/>		characterCount(str); <br/>	} <br/>} </code></pre> </div>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">Output<br/>c 1<br/>t 1<br/>e 1<br/>W 1<br/>h 1<br/>i 2<br/>y 1<br/>k 1</code></pre> </div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
