Kth Distinct String in an Array Problem

Kth Distinct String in an Array Problem — ExecCode Easy DSA Practice

Solve the Kth Distinct String in an Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array of strings arr, and an integer k, return the k^th distinct string present in arr. Your task is to if there are fewer than k distinct strings, return an empty string "". A distinct string is a string that is present only once in an array. Note that the strings are considered in the order in which they appear in the array.

Examples

Input {"arr": ["d", "b", "c", "b", "c", "a"], "k": 2}; Output a. Input {"arr": ["aaa", "aa", "a"], "k": 1}; Output aaa

Constraints

1 <= k <= arr.length <= 1000 1 <= arr[i].length <= 5 arr[i] consists of lowercase English letters.

Practice Kth Distinct String in an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.