반응형
https://leetcode.com/problems/add-strings/description/
Add Strings - LeetCode
Can you solve this real interview question? Add Strings - Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large in
leetcode.com
bigint 연산을 지원하는 python을 이용해 해결했습니다.
📕 풀이방법
📔 풀이과정
type을 int로 casting 후 더한 결과를 str로 casting해줍니다.
📔 정답 출력 | 반환
casting된 결과를 반환합니다.
📕 Code
📔 Python
class Solution(object):
def addStrings(self, num1, num2):
return str(int(num1) + int(num2))
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - LeetCode (easy) 461. Hamming Distance (0) | 2023.03.23 |
---|---|
(C++) - LeetCode (easy) 441. Arranging Coins (0) | 2023.03.15 |
(C++) - LeetCode (easy) 409. Longest Palindrome (0) | 2023.03.09 |
(C++) - LeetCode (easy) 405. Convert a Number to Hexadecimal (0) | 2023.03.07 |
(C++) - LeetCode (easy) 342. Power of Four (0) | 2023.02.15 |