+ 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

4th Mar 2020, 8:24 PM
Microne mafika
Microne mafika - avatar
12 Réponses
+ 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)
4th Mar 2020, 8:39 PM
Jayakrishna 🇮🇳
+ 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...
4th Mar 2020, 8:49 PM
Jayakrishna 🇮🇳
+ 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..
4th Mar 2020, 9:12 PM
Jayakrishna 🇮🇳
+ 1
yes why 6 insted of 1
4th Mar 2020, 8:40 PM
Microne mafika
Microne mafika - avatar
+ 1
I want to find the number of chars which are in s1 or chars dont match
4th Mar 2020, 8:42 PM
Microne mafika
Microne mafika - avatar
+ 1
Not 6, it's 13. I just put example, now updated total see again...
4th Mar 2020, 8:44 PM
Jayakrishna 🇮🇳
+ 1
im getting -9
4th Mar 2020, 8:54 PM
Microne mafika
Microne mafika - avatar
+ 1
You did not changed != to ==. Comparing equals then subtracting from total length will give unequal characters...
4th Mar 2020, 9:00 PM
Jayakrishna 🇮🇳
+ 1
thank you sir
4th Mar 2020, 9:05 PM
Microne mafika
Microne mafika - avatar
0
You did get 1, i ran it
6th Mar 2020, 12:27 PM
Anh Thu LE
Anh Thu LE - avatar
0
in string you are comparing word as per index i
12th Mar 2020, 12:24 PM
Shubham Bodhane
Shubham Bodhane - avatar