`{"id":"b5d307ad-bb16-47e8-b9bd-436ff72342c3","name":"Add Strings","description":"1. Given two non-negative integers, num1 and num2 represented as string.\r\n2. Return the sum of num1 and num2 as a string.\r\n3. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). \r\n4. You must also not convert the inputs to integers directly.\r\n","inputFormat":"n1 = \"1234\"\r\nn2 = \"897\"\r\n","outputFormat":"res = \"2131\"","constraints":"1. 1 &lt;= num1.length, num2.length &lt;= 10^4\r\n2. num1 and num2 consist of only digits.\r\n3. num1 and num2 don't have any leading zeros except for the zero itself.\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n string addStrings(string num1, string num2) {\n \n \n }\n int main()\n {\n \n string n1,n2;\n cin>>n1;\n cin>>n2;\n\n string res = addStrings(n1, n2);\n cout<<res;\n }"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String addStrings(String num1, String num2) {\r\n // write your code here\r\n }\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String n1 = scn.nextLine();\r\n String n2 = scn.nextLine();\r\n\r\n String res = addStrings(n1, n2);\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1234\r\n798","sampleOutput":"2032","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"ec6d65e8-0ffe-4585-bde1-89294d9b3624","name":"Add Strings","slug":"add-strings","type":1}],"next":{"id":"66f8f75d-8e1d-4587-8eba-ea3405de5d0e","name":"Add Strings","type":3,"slug":"add-strings"},"prev":{"id":"31f6bd4d-257d-43ef-9283-7225899783e3","name":"Best Meeting Point MCQ","type":0,"slug":"best-meeting-point-mcq"}}}`

1. Given two non-negative integers, num1 and num2 represented as string. 2. Return the sum of num1 and num2 as a string. 3. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). 4. You must also not convert the inputs to integers directly.

`{"id":"b5d307ad-bb16-47e8-b9bd-436ff72342c3","name":"Add Strings","description":"1. Given two non-negative integers, num1 and num2 represented as string.\r\n2. Return the sum of num1 and num2 as a string.\r\n3. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). \r\n4. You must also not convert the inputs to integers directly.\r\n","inputFormat":"n1 = \"1234\"\r\nn2 = \"897\"\r\n","outputFormat":"res = \"2131\"","constraints":"1. 1 &lt;= num1.length, num2.length &lt;= 10^4\r\n2. num1 and num2 consist of only digits.\r\n3. num1 and num2 don't have any leading zeros except for the zero itself.\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n string addStrings(string num1, string num2) {\n \n \n }\n int main()\n {\n \n string n1,n2;\n cin>>n1;\n cin>>n2;\n\n string res = addStrings(n1, n2);\n cout<<res;\n }"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String addStrings(String num1, String num2) {\r\n // write your code here\r\n }\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String n1 = scn.nextLine();\r\n String n2 = scn.nextLine();\r\n\r\n String res = addStrings(n1, n2);\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1234\r\n798","sampleOutput":"2032","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"ec6d65e8-0ffe-4585-bde1-89294d9b3624","name":"Add Strings","slug":"add-strings","type":1}],"next":{"id":"66f8f75d-8e1d-4587-8eba-ea3405de5d0e","name":"Add Strings","type":3,"slug":"add-strings"},"prev":{"id":"31f6bd4d-257d-43ef-9283-7225899783e3","name":"Best Meeting Point MCQ","type":0,"slug":"best-meeting-point-mcq"}}}`

Editor

easy

1. Given two non-negative integers, num1 and num2 represented as string. 2. Return the sum of num1 and num2 as a string. 3. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). 4. You must also not convert the inputs to integers directly.

## Constraints

1. 1 <= num1.length, num2.length <= 10^4 2. num1 and num2 consist of only digits. 3. num1 and num2 don't have any leading zeros except for the zero itself.

## Format

### Input

n1 = "1234" n2 = "897"

res = "2131"

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}1234 798```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}2032`

Discussions

Show Discussion

Related Resources