Carry2 [LeetCode] 2. Add Two Numbers 접근 두 노드를 순회하며 계산 친절하게도 이미 거꾸로 뒤업어 놓았음 carry 를 활용해서 모든 경우의 수에 부합하는 보편적인 문제 해결 방식을 찾아야 솔루션 class Solution: def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: answer = ListNode(0, None) answer_cursor = answer carry = 0 while l1 != None or l2 != None or carry != 0: l1Value = 0 l2Value = 0 if l1: l1Value = l1.val if l2: l2Value = l2.val sumOfValue = l1Value.. 2023. 3. 13. [LeetCode] 989. Add to Array-Form of Integer https://leetcode.com/problems/add-to-array-form-of-integer Add to Array-Form of Integer - LeetCode Add to Array-Form of Integer - The array-form of an integer num is an array representing its digits in left to right order. * For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the ar leetcode.com 접근 정수 배열인 num 을 정수로 바꾸어 num 과.. 2023. 2. 15. 이전 1 다음