-
Notifications
You must be signed in to change notification settings - Fork 28
/
debug.py
39 lines (35 loc) · 961 Bytes
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pysnooper
@pysnooper.snoop()
def findDuplicates(nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
res = []
for i in range(len(nums)):
while i != nums[i]-1:
if nums[i] != nums[nums[i]-1]:
tmp = nums[i]
nums[i] = nums[nums[i]-1]
nums[tmp-1] = tmp
else:
res.append(nums[i])
break
return res
@pysnooper.snoop()
def transpose(A):
"""
:type A: List[List[int]]
:rtype: List[List[int]]
"""
res = []
for i in range(len(A[0])):
res.append([A[0][i]])
for col in range(1,len(res)):
for i in range(len(A[0])):
res[i].append(A[col][i])
return res
if __name__=='__main__':
# findDuplicates([4,3,2,7,8,2,3,1])
x = [[1,2,3],[4,5,6]]
transpose(x)