Digital dictionary

Getting testcase 1, 2 and 3 wrong

@Rakshitgarg99
Consider this testcase
4
pet
peter
rat
rack
3
flag

Output should be “No suggestions” but your code is giving no output. Dry run your code for this case.


done some changes but not get correct answer

@Rakshitgarg99
Now the problem is if a particular string came more than once while insertion. You don’t to print it multiple time. Consider this test
2
rat
rat
1
ra
Out should be
rat
But your code is givin
rat
rat

Inorder to fix this add if(it>0 && v[it-1]==temp){ continue; } after line 39.

@Rakshitgarg99
Here is the updated code


It’s is working fine for all testcases.

thanks. but why you add this if(it>0 && v[it-1]==temp){ continue; }

@Rakshitgarg99
It mean that if temp exist before it index, you don’t have to print it again. Bcz it’s already get printed before it index

can you please provide the testcase or an example in which it is printed again. It will help as a future reference

@Rakshitgarg99
Consider this testcase
3
rat
ram
rat
1
ra

In output ram get printed twice but it must be printed only once

Now i get it. Thanks bhaiya

1 Like

@Rakshitgarg99
Mark this doubt as resolved :slight_smile: