Skip to content

Commit 943974c

Browse files
committed
add Python 21,22 solutions
1 parent db34c3b commit 943974c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution(object):
2+
def minFlips(self, target):
3+
"""
4+
:type target: str
5+
:rtype: int
6+
"""
7+
res= 0
8+
s ="0"
9+
for c in target:
10+
if c != s:
11+
res += 1
12+
s = c
13+
return res
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution(object):
2+
def mergeAlternately(self, word1, word2):
3+
"""
4+
:type word1: str
5+
:type word2: str
6+
:rtype: str
7+
"""
8+
l1 = len(word1)
9+
l2 = len(word2)
10+
i,j = 0,0
11+
res = list()
12+
while i < l1 or j < l2:
13+
if i < l1:
14+
res.append(word1[i])
15+
i += 1
16+
if j < l2:
17+
res.append(word2[j])
18+
j += 1
19+
20+
return "".join(res)

0 commit comments

Comments
 (0)