i watched other videos, but personally i pretty much like the breakdown of your explanation esp around the using of ascii to deduct the numbers to obtain an integer.
I'm not sure what the equivalent would be in C++, but a StringBuilder class allows you to mutate a string while using the default String class is immutable.
import java.util.* ; import java.io.*; public class Solution { public static String stringConcatenation(String num1, String num2) { int sum=Integer.parseInt(num1)+Integer.parseInt(num2); String s=String.valueOf(sum); return s; // Write your code here. } } what is the time complexity of this code?
Better explanation than any other videos for the same problem
i watched other videos, but personally i pretty much like the breakdown of your explanation esp around the using of ascii to deduct the numbers to obtain an integer.
Excellent as always, can't be more clear. I am a big fan of yours, please please please please do more videos!!! More!!!
More to come!
Thank you for the clear explanation
No worries!
Great explanation. Thanks.
Glad it was helpful!
Best explanation, thanks
Glad it was helpful!
Incredibly easy to understand, thank you
i think the cat is also interested in string problem too. :)
Hahaha agreed
Awesome explanation!
I have a question that we return .toString( ) in the end because if we don't do so, the return type is StringBuilder? ( I am a Java beginner x.x)
Yep, that is correct!
What is the approach if the added number can be less than zero.
Amazing, thank you
No problem!
Really loved it sir..!!
Glad to hear that
How who the code be in C++ becasue string builder, what is that?
I'm not sure what the equivalent would be in C++, but a StringBuilder class allows you to mutate a string while using the default String class is immutable.
Great Explanation. Subscribed...
My python implementation:
class Solution:
def addStrings(self, num1: str, num2: str) -> str:
i = len(num1)-1
j = len(num2)-1
res = []
carry = 0
while i >= 0 or j >= 0:
if i >= 0:
x = ord(num1[i]) - ord("0")
else:
x = 0
if j >= 0:
y = ord(num2[j]) - ord("0")
else:
y = 0
add = x + y + carry
res.append(str(add%10))
carry = add // 10
i -= 1
j -= 1
if carry:
res.append(str(carry))
return "".join(res)[::-1]
man your cat looks like he is about to attack on you :D
LOL I wouldn't be surprised if he did honestly
Is your cat real? It is not moving at all, lol
import java.util.* ;
import java.io.*;
public class Solution {
public static String stringConcatenation(String num1, String num2) {
int sum=Integer.parseInt(num1)+Integer.parseInt(num2);
String s=String.valueOf(sum);
return s;
// Write your code here.
}
}
what is the time complexity of this code?