Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/easy/read_binary_watch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
@author: loopgan
@contact: [email protected]
@time: 18-10-10 上午12:24
"""


class Solution:
def readBinaryWatch(self, num):
"""
:type num: int
:rtype: List[str]
"""
return ['%d:%02d' % (h, m) for h in range(12) for m in range(60) if (bin(h) + bin(m)).count('1') == num]


if __name__ == "__main__":
num = 1
ss = Solution()
print(ss.readBinaryWatch(num))
# print("Hello imp")
40 changes: 40 additions & 0 deletions src/easy/rotate_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
@author: loopgan
@contact: [email protected]
@time: 18-10-10 上午12:58
"""


class Solution:
def rotateString(self, A, B):
"""
:type A: str
:type B: str
:rtype: bool
"""
if len(A) != len(B):
return False
else:
if len(A) == 0:
return True
for i in range(len(B), 0, -1):
if i == 0:
return False
if B[0:i] in A:
if B[i:] in A:
return True
else:
return False
else:
return False


if __name__ == "__main__":
A = 'abcde'
B = 'cdeab'
ss = Solution()
print(ss.rotateString(A, B))
print("Hello imp")
29 changes: 29 additions & 0 deletions src/easy/set_mismatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
@author: loopgan
@contact: [email protected]
@time: 18-9-5 上午12:01
"""


class Solution:
def findErrorNums(self, nums):
tmp = [i + 1 for i in range(len(nums))]
r = 0
zz = []
for i in nums:
if i in zz:
r = i
else:
zz.append(i)
lack = list(set(tmp).difference(set(nums)))[0]
return r, lack


if __name__ == "__main__":
s = [1, 2, 2, 4]
ss = Solution()
print(ss.findErrorNums(s))
print("Hello imp")