0

Please explain, I just do not understand

Can you explain this code to me. I canā€™t understand how, when I type in the words hello, ā€œDeja Vuā€ is displayed. It is not clear what each "for" line is responsible for. ŠœŠ¾Š¶Š½Š¾ Šø Š½Š° руссŠŗŠ¾Š¼ Š¾Ń‚Š²ŠµŃ‚Šøть. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string vvod = Convert.ToString(Console.ReadLine()); string result = "Unique"; for (int i = 0; i < vvod.Length; i++) { for (int j = 1; j < vvod.Length - i; j++) { if(vvod[i] == vvod[j + i]) { result = "Deja Vu"; } } } Console.Write(result); } } }

25th Mar 2020, 10:15 PM
GAG98
GAG98 - avatar
3 Answers
0
Is it not your code? This is for code coach problem.. Description you can find from link below clearly... For loop check, if there is dublicates charecters in given input... Test with Input: abb abc https://www.sololearn.com/coach/54?ref=app
26th Mar 2020, 8:21 AM
Jayakrishna šŸ‡®šŸ‡³
0
No, this is not mine. I canā€™t understand why i = 0, j = 1 and vvod [i] == vvod [i + j]
26th Mar 2020, 9:38 AM
GAG98
GAG98 - avatar
0
There should be actually j start from j=i+1. Because if it atleast, one character dublicate charecter should be there to change result to "Deja vu". Ex: If input: abcde i=0 to 4 j=1 to 4-i i, j : 0, 1 to 4, j+i=1+0= so 1 to 4 a!=b, a!=c, a!=d, a!=e I, j : 1 , 1 to 3, in if I, j =>1, 2 & 1,3 b! =c, b!=d Next I, j : 2, 1 to 4-2=2 so I, j =>2, 3, c!=d, c!=e Next I, j: 3 , 1 to 4-3=1 so no comparison...... No further comparison...
26th Mar 2020, 12:07 PM
Jayakrishna šŸ‡®šŸ‡³