일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 링피트
- 괜찮음
- 스탭퍼
- 만화도
- 운동
- 미드시청
- realclass
- 개발자
- FIT XR
- 화상영어
- 프로젝트
- 영어공부
- 10분
- 3줄정리
- 잡생각
- 리얼 클래스
- Daily Challenge
- 월간
- 파비최
- 뭐든
- Writing
- 사이드
- 쓰릴오브파이트
- 매일
- 영어원서읽기
- Problem Solving
- leetcode
- 읽기
- English
- 30분
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.05.17 Today's Challenge 본문
https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/
Maximum Twin Sum of a Linked List - LeetCode
Can you solve this real interview question? Maximum Twin Sum of a Linked List - In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1. * For example, if
leetcode.com
오늘도 리스트 문제
class Solution:
def pairSum(self, head: Optional[ListNode]) -> int:
cur = head
val = []
while cur:
val.append(cur.val)
cur = cur.next
i = 0
j = len(val) - 1
res = 0
while(i < j):
res = max(res, val[i] + val[j])
i += 1
j -= 1
return res
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.05.19 Today's Challenge (0) | 2023.05.19 |
---|---|
2023.05.18 Today's Challenge (0) | 2023.05.18 |
2023.05.16 Today's Challenge (0) | 2023.05.16 |
2023.05.15 Today's Challenge (1) | 2023.05.15 |
2023.05.14 Today's Challenge (0) | 2023.05.14 |
Comments