Skip to content

Commit 0870eda

Browse files
authored
Create generate-a-string-with-characters-that-have-odd-counts.py
1 parent f792dc8 commit 0870eda

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def generateTheString(self, n):
6+
"""
7+
:type n: int
8+
:rtype: str
9+
"""
10+
result = ['a']*(n-1)
11+
result.append('a' if n%2 else 'b')
12+
return "".join(result)

0 commit comments

Comments
 (0)