본문 바로가기

Algorithm/Implementation

(Python) - LeetCode (easy) 415. Add Strings

반응형

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))

*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.