Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 그리디
- 파이썬
- mobaXTerm
- docker
- Backjoon
- cpu scheduling
- GCP
- Codility
- KAKAO
- java
- Kotlin
- easy
- 백준
- go
- 알고리즘
- Dynamic Programming
- golang
- Observer Pattern
- BubbleSort
- kubernetes
- Top-down
- 피보나치
- Python
- github
- Singleton Pattern
- LeetCode
- Programmers
- GKE
- k8s
Archives
- Today
- Total
To Be Developer
[LeetCode] 796. Rotate String Python 본문
class Solution(object):
class Solution(object):
def rotateString(self, A, B):
"""
:type A: str
:type B: str
:rtype: bool
"""
# input A 의 길이
ln = len(A)
# input B 의 길이
lnB = len(B)
# input data가 "" 이면 True
if ln == lnB == 0:
return True
# 길이가 같지 않으면 False
if ln != lnB:
return False
# 0 ~ ln-1 까지 반복
for i in range(ln):
# A[i~ln-1] + A[0~i] 가 B 와 같으면 True
if A[i::]+A[:i] == B:
return True
# 반복문을 무사 통과하면 return False
return False
if __name__ == "__main__":
A = "abcde"
B = "cdeab"
sl = Solution().rotateString(A,B)
print(sl)
'알고리즘 > LeetCode' 카테고리의 다른 글
| [LeetCode] 88. Merge Sorted Array Python (0) | 2019.03.29 |
|---|---|
| [LeetCode] 917. Reverse Only Letter Python (0) | 2019.03.27 |
| [LeetCode] 1020. Partion Array Into Three Parts With Equal Sum Python (0) | 2019.03.26 |
| [LeetCode] 476. Number Complement (0) | 2019.03.25 |
| [LeetCode] 942. DI String Match Python (0) | 2019.03.25 |