• + 0 comments

    F# Pipeline Solution

    for T in 1..(stdin.ReadLine() |> int) do
        let K = stdin.ReadLine().Split()|>Array.map int |> fun a -> a.[1]
        stdin.ReadLine().Split()
         |> Array.countBy id
         |> Array.filter (fun (_,count) -> count >= K)
            |> function
                | [||] -> printfn "-1"
                | lst -> lst 
                            |> Array.map fst 
                            |> String.concat " " 
                            |> printfn "%s"