Sorting 第一題:【Distinct】
Compute number of distinct values in an array.
Write a function
def solution(A)
that, given a zero-indexed array A consisting of N integers,
returns the number of distinct values in array A.
方法一:直接取 set 長度的簡易方法
Correctness:100%、Performance:100%
def solution(A):
return len(set(A))
完整練習題 source code 請參閱:github
沒有留言:
張貼留言