I am practicing some questions from the Codility. However every time I run the questions I am getting a very low score(25%) for the performance(runtime). Can you help me know how to improve my codes so as to score a better score?
The question is:
Write a function:
def solution(A)
that, given an array A consisting of N integers fulfilling the above conditions, returns the value of the unpaired element.
For example, given array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3 A[4] = 9 A[5] = 7
A[6] = 9
the function should return 7, as explained in the example above.
And My code for the same is:
def solution(A):
# write your code in Python 3.6
lis=[i for i in A if A.count(i) ==1]
return lis[0]
Output:
medium2 "medium random test n=100,003 ✘TIMEOUT ERROR Killed. Hard limit reached: 6.000 sec"