PermCheck

 1         /// <summary>
 2         /// Solution
 3         /// 通过率 100%
 4         /// </summary>
 5         /// <param name="A"></param>
 6         /// <returns></returns>
 7         public static int solution(int[] A)
 8         {
 9             HashSet<int> hs = new HashSet<int>();
10             foreach (int num in A)
11             {
12                 if (!hs.Contains(num) && num <= A.Length)
13                     hs.Add(num);
14                 else
15                     return 0;
16             }
17             return 1;
18         }
时间: 2024-10-06 05:32:07

PermCheck的相关文章