using System.Collections;
public void secondmost(string[] arr)
Hashtable ht = new Hashtable();
for (int i = 0; i < arr.Length; i++)
if (ht.ContainsKey(arr[i]))
ht[arr[i]] = Convert.ToInt32(ht[arr[i]]) + 1;
if (Convert.ToInt32(ht[arr[i]]) > max)
max = Convert.ToInt32(ht[arr[i]]);
foreach (var iems in ht.Keys)
if (Convert.ToInt32(ht[iems]) > second)
if (Convert.ToInt32(ht[iems]) < max)
second = Convert.ToInt32(ht[iems]);
foreach (var iems in ht.Keys)
if (Convert.ToInt32(ht[iems]) == second)
public static void Main()
string[] arr = new string[]{"geek", "for", "geek", "for", "geek","aaa","aaa"};
Program p = new Program();