1、用双重循环逐个遍历(超时)

2、用list B的append和remove函数(超时)

3、用dict B(AC)

 1 class Solution:
 2     # @param A, a list of integer
 3     # @return an integer
 4     def singleNumber(self, A):
 5         B = {}
 6         for i in A:
 7             if i not in B:
 8                 B[i] = 1
 9             else:
10                 B[i] = 2
11         for i in B:
12             if B[i] == 1:
13                 ret = i
14                 break
15         return ret

 

相关文章:

  • 2022-12-23
  • 2021-08-15
  • 2021-11-24
  • 2021-10-16
  • 2021-05-22
  • 2021-07-10
  • 2022-02-25
  • 2022-02-15
猜你喜欢
  • 2021-10-07
  • 2021-06-10
  • 2021-09-01
  • 2021-08-26
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
相关资源
相似解决方案