Doubt in my code

Hello, Is this code correct. Because it is working well but are there any possibilities where it may fail ?

Here is my code :

Hey @yashsharma4304 , hope you are doing good. I want to know the logic you are using in this code as the problem you have tagged is to find largest string in n strings and What you are Doing in this code is removing two adjacent duplicate characters.

The logic is similar to that of prateek sir explained but what is a little different is I have initialised the value of larg array as null character. And if we talk about the logic I have used then it is like:

I have taken the input (the number of strings) from user and stored it inside the variable n

Then I have initialized two arrays one is the larg array which stores the largest string but initially it is storing the null character so I have initialized it with a value of null.

Another array is current which stores the current string

Now I have started a loop which takes a string and stores it inside current and everytime it will compare that string with the string inside larg. If the string inside larg is smaller than current then I replaced it by current string.

In this way I will get the largest string inside the larg and I will print it.

But the code you have shared with doesn’t have two arrays
This is the code you have shared with me @yashsharma4304

Is this the code you are talking about?

Ok wait I have not saved the code let me save it.

Yes this code is appropriate in every way. It won’t fail for any test case for sure if it’s to find largest string out of n string. Also you have wrote a clean code :slight_smile: good job my friend :+1:

1 Like

Thank u for your appreciation :relaxed:. Also thanks a lot for clearing my doubt. :slightly_smiling_face: :slightly_smiling_face:

1 Like

Your welcome buddy @yashsharma4304