+ 2
Can someone figure out why I’m not getting 1 as as answer.
I WANT TO FIND CHARS WHICH ARE NOT IN T1 BUT IN T2 https://code.sololearn.com/cCq59cWA5K51/?ref=app
12 Respuestas
+ 3
Your comparing like every character of str1 to every character of string2
So a! =b, c, p=>count=3
b!= a, c, p =>count =6
c! = a, b, p =>count=9
t! = a, b, c, p =>count=13
(Updated for total iterations)
+ 2
By this approach, try like
if(str1[i] == str2[j])
count++;
Now count contains matched characters.
str1. Length - count gives number charecter that does not match...
+ 2
Program is fine but You should write less calculations in loops..
Take count as return from function. (not y)
And write like
Console.Write(t1.Length - countChar(t1,t2));
Why to convert toString..? No need.
And you're welcome..
+ 1
yes why 6 insted of 1
+ 1
I want to find the number of chars which are in s1 or chars dont match
+ 1
Not 6, it's 13. I just put example, now updated total see again...
+ 1
im getting -9
+ 1
You did not changed != to ==.
Comparing equals then subtracting from total length will give unequal characters...
+ 1
thank you sir
0
You did get 1, i ran it
0
in string you are comparing word as per index i