Category Archives: Hash

k-th distinct (non-repeating) element in an Array

Given an integer array arr[] a non negative integer k, print k-th distinct element in an array. The given array may contain duplicates and the output should print k-th distinct element among all elements in the array. If k is more than number of distinct elements, print -1. Examples : Input : arr[] = {1, 2, 1, 3,… Read More »