【Google真题】 Who is unique? 100%AC python

【Google真题】 Who is unique? 100%AC python

In a class, V students are standing in a row (consider 1-basedindexing). Every student is wearing some colored t-shirt. A studentis unique if they wear a t-shirt whose color is different fromeveryone else’s. You have to tell who all are unique students.

Input format:

First line: single integer T’ - number of test cases.

For each test case:
First line: single integer V - number of students standing in
a row
Second line: Color1, Color2,…,Colorn-1, Colorn.Here,Color, is the color of the t-shirt of the ith student and
Colori e [A, Z i.e, upper case English alphabets.

Output format:

Count of students who are unique and the position of all thosestudents in increasing order in a separate line.

思路:

使用dict记录第一次出现的位置,使用set来记录是否是第一次出现

最后遍历set把位置

你可能感兴趣的:(OA真题,python,开发语言,OA,Google)