Skip to content

Commit e76e5c5

Browse files
committed
practice in Python
1 parent 83f19f1 commit e76e5c5

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

python/index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,6 @@ def replaceDigits(s: str) -> str:
268268
# print(replaceDigits(s))
269269

270270

271+
a = [12,6,3]
272+
b = map(lambda x: x * 2, a)
273+
print(list(b))

python/leetcode/list/136.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def singleNumber(nums: List[int]) -> int:
2+
'''
3+
136. Single Number
4+
'''
5+
# 找出只出現一次的元素
6+
# ans = 0
7+
# for key,value in Counter(nums).items():
8+
# if(value == 1):
9+
# ans = key
10+
# return ans
11+
12+
# solution 2
13+
ans = 0
14+
for i in nums:
15+
ans ^= i
16+
return ans
17+
18+
19+
nums = [4,1,2,1,2]
20+
# 4
21+
print(singleNumber(nums))

0 commit comments

Comments
 (0)