일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Problem Solving
- 쓰릴오브파이트
- 괜찮음
- 뭐든
- 영어원서읽기
- Writing
- realclass
- 미드시청
- Daily Challenge
- English
- 3줄정리
- 매일
- 리얼 클래스
- 개발자
- 영어공부
- 운동
- 10분
- FIT XR
- 화상영어
- 만화도
- 30분
- 사이드
- 파비최
- 잡생각
- 프로젝트
- 스탭퍼
- 읽기
- 링피트
- 월간
- leetcode
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.10.30 Today's Challenge 본문
https://leetcode.com/problems/count-vowels-permutation/?envType=daily-question&envId=2023-10-28
Count Vowels Permutation - LeetCode
Can you solve this real interview question? Count Vowels Permutation - Given an integer n, your task is to count how many strings of length n can be formed under the following rules: * Each character is a lower case vowel ('a', 'e', 'i', 'o', 'u') * Each
leetcode.com
이것도 왜 hard지..?
class Solution:
def countVowelPermutation(self, n: int) -> int:
MOD = 10**9 + 7
a, e, i, o, u = 1, 1, 1, 1, 1
for _ in range(1, n):
a_next = e
e_next = (a + i) % MOD
i_next = (a + e + o + u) % MOD
o_next = (i + u) % MOD
u_next = a
a, e, i, o, u = a_next, e_next, i_next, o_next, u_next
return (a + e + i + o + u) % MOD
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.11.01 Today's Challenge (0) | 2023.11.01 |
---|---|
2023.10.31 Today's Challenge (0) | 2023.10.31 |
2023.10.29 Today's Challenge (0) | 2023.10.29 |
2023.10.28 Today's Challenge (0) | 2023.10.28 |
2023.10.27 Today's Challenge (0) | 2023.10.27 |
Comments