일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Problem Solving
- 미드시청
- Daily Challenge
- leetcode
- 3줄정리
- 스탭퍼
- 프로젝트
- 리얼 클래스
- 개발자
- 읽기
- 월간
- 30분
- 괜찮음
- English
- 뭐든
- 영어원서읽기
- 만화도
- FIT XR
- 사이드
- 파비최
- 쓰릴오브파이트
- 영어공부
- 10분
- 매일
- Writing
- 운동
- 잡생각
- 링피트
- 화상영어
- realclass
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