
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Concatenate Two Strings
								Certification: Basic Level
								Accuracy: 64.71%
								Submissions: 17
								Points: 10
							
							Write a C++ program that concatenates two strings without using the `strcat()` function.
Example 1
- Input: string1 = "Hello", string2 = "World"
- Output: "HelloWorld"
- Explanation:
    - Step 1: Create a new string with size equal to the sum of lengths of both input strings.
- Step 2: Copy characters from the first string to the new string.
- Step 3: Append characters from the second string to the new string.
- Step 4: Return the concatenated string.
 
Example 2
- Input: string1 = "C++", string2 = "Programming"
- Output: "C++Programming"
- Explanation:
    - Step 1: Create a new string with size equal to the sum of lengths of both input strings.
- Step 2: Copy characters from the first string to the new string.
- Step 3: Append characters from the second string to the new string.
- Step 4: Return the concatenated string.
 
Constraints
- 1 ≤ len(string1), len(string2) ≤ 10^6
- The strings contain printable ASCII characters.
- Time Complexity: O(n + m), where n and m are the lengths of the two strings
- Space Complexity: O(n + m)
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Create a new string with enough space to hold both strings.
- Copy the characters of the first string into the new string.
- Append the characters of the second string to the new string.
