일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 쓰릴오브파이트
- 링피트
- 운동
- 파비최
- 사이드
- 잡생각
- Daily Challenge
- 3줄정리
- leetcode
- Writing
- 10분
- realclass
- 30분
- 월간
- 개발자
- 뭐든
- Problem Solving
- FIT XR
- 스탭퍼
- 만화도
- 미드시청
- 괜찮음
- 매일
- 영어원서읽기
- 읽기
- 영어공부
- English
- 리얼 클래스
- 화상영어
- 프로젝트
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.04.18 Today's Challenge 본문
https://leetcode.com/problems/merge-strings-alternately/
Merge Strings Alternately - LeetCode
Can you solve this real interview question? Merge Strings Alternately - You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional le
leetcode.com
오늘도 대충 풀면 되는 문제!
class Solution:
def mergeAlternately(self, word1: str, word2: str) -> str:
res = []
l1, l2 = len(word1), len(word2)
for i in range(max(l1, l2)):
if l1 > i:
res.append(word1[i])
if l2 > i:
res.append(word2[i])
return ''.join(res)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.04.20 Today's Challenge (0) | 2023.04.20 |
---|---|
2023.04.19 Today's Challenge (0) | 2023.04.19 |
2023.04.17 Today's Challenge (0) | 2023.04.17 |
2023.04.16 Today's Challenge (0) | 2023.04.16 |
2023.04.15 Today's Challenge (0) | 2023.04.15 |
Comments