Quick actions

cmd+k|ctrl+k

Navigation

Languages

HashTable-FindFirstRecurringChar

Snippet info

Language

Csharp

Visibility

public

Author

dhaval-90

Created

2022-03-04T09:28:20.608981Z

Updated

2022-03-04T09:28:54.570854Z

using System;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        int[] arr = { 1, 5, 8, 5, 1, 8, 8, 7, 4, 4, 10 };
        Console.Write(FindFirstRecurringChar(arr));
    }

    static int FindFirstRecurringChar(int[] arr)
    {
        Hashtable h = new Hashtable();
        for (int i = 0; i < arr.Length; i++)
        {
            if(h.ContainsKey(arr[i]))
            {
                return arr[i];
            }
            h[arr[i]] = arr[i];
        }
        return 0;
    }
}
INFO