using System.Collections.Generic;
public static void Main()
var result = getShortestUniqueString(new char[] { 'x', 'y', 'z' }, "yxyyzyzxzzyx");
Console.WriteLine(result);
static string getShortestUniqueString(char[] arr, string str)
var used = new Queue<char>(arr.Length);
for (int i = 0; i < str.Length; i++)
if (rest.Contains(str[i]))
while ((ch = used.Dequeue()) != str[i])
return str.Substring(i + 1 - arr.Length, arr.Length);