if(A == ): return 0 A=[i for i in A if (i != elem)] return len(A)
Input: [4,5], 4
It seems that your code did nothing to the original list A. You created a new list named 'A' in line 3 in your code, and it only looks the same as what should return. Of course, the length is 1, which is correct, so the OJ cut the original input list at position 1 and gave WA.
Maybe you can try to create a list to record the occurrences of 'elem' and use A.remove(elem) to pass OJ.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.