宏軍的學習筆記
Counting Elements 練習題的第二題題目是【PermCheck】 Check whether array A is a permutation.
方法一:使用 set 判斷長度是否一致的簡易方式
def solutionBySet(A): S = set(A) return 1 if max(S) == len(S) and len(S) == len(A) else 0;
完整練習題 source code 請參閱:github
沒有留言:
張貼留言