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 | 31 |
Tags
- PytorchLightning
- github
- rnn
- pytorch
- GCP
- FDS
- Matplotlib
- autoencoder
- DeepLearning
- NaverAItech
- 알고리즘
- wandb
- vscode
- datascience
- 백준
- docker
- 프로그래머스
- torchserve
- FastAPI
- 완전탐색
- pep8
- 코딩테스트
- python
- 네이버AItech
- GitHub Action
- leetcode
- NLP
- Kaggle
- GIT
- Kubernetes
Archives
- Today
- Total
Sangmun
459. Repeated Substring Pattern 본문
https://leetcode.com/problems/repeated-substring-pattern/
Repeated Substring Pattern - LeetCode
Can you solve this real interview question? Repeated Substring Pattern - Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. Example 1: Input: s = "abab" Output: true Expl
leetcode.com
문자열의 길이가 최대 10000까지 주어져서 일일이 substring을 나눠서 True/False를 판독하면 시간초과가 걸릴 줄 알았으나 그렇게 풀어도 통과과 됨
def repeatedSubstringPattern(s: str) -> bool:
n = len(s)
for i in range(1, n // 2 + 1):
if n % i == 0:
substring = s[:i]
if substring * (n // i) == s:
return True
return False
'알고리즘 > 리트코드' 카테고리의 다른 글
283. Move Zeroes (0) | 2023.05.04 |
---|---|
Palindrome (0) | 2023.04.27 |
516. Longest Palindromic Subsequence (0) | 2023.04.22 |
662. Maximum Width of Binary Tree (0) | 2023.04.20 |
Leet code Validate Stack Sequences (0) | 2023.04.13 |
Comments