Input = INDIA, count each char in input string
class Program { static void Main() { // Input string string input = "INDIA"; // Call the method to count occurrences var charCount = new Dictionary<char, int>(); // Iterate through each character in the string foreach (var c in input) { // Check if the character is already in the dictionary if (charCount.ContainsKey(c)) { // Increment the count of the character charCount[c]++; } else { ...
Comments
Post a Comment