- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to add two numbers represented as strings in Python
Suppose we have two strings S, and T, these two are representing an integer, we have to add them and find the result in the same string representation.
So, if the input is like "256478921657", "5871257468", then the output will be "262350179125", as 256478921657 + 5871257468 = 262350179125
To solve this, we will follow these steps −
- convert S and T from string to integer
- ret = S + T
- return ret as string
Let us see the following implementation to get better understanding −
class Solution: def solve(self, a, b): return str(int(a) + int(b)) ob = Solution() print(ob.solve("256478921657", "5871257468"))
- Add two numbers represented by two arrays in C Program
- Multiply Large Numbers represented as Strings in C++
- Add two numbers represented by linked lists?
- Program to find numbers represented as linked lists in Python
- Python program to add two numbers
- Why are numbers represented as objects in python?
- Java Program to Add Two Binary Strings
- Add Two Numbers in Python
- Java Program to Add Two Numbers
- C++ Program to Add Two Numbers
- Program to add two binary strings in C++
- Program to add two binary strings, and return also as binary string in C++
- Add 1 to a number represented as linked list?
- Add 1 to number represented as array (Recursive Approach)?
- Multiply two numbers represented as linked lists into a third list in C++