Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Given n, which is the number of strings taken as input. For each input use have to print “YES” or “NO” whether the current string is already present or not.

Input:
5
Geeks
Hello
Great
Geeks
Hello
Output:

No
No
No
Yes
Yes

What I have tried:

bool isSubSequence(char str1[], char str2[], int m, int n)
{
    // Base Cases
    if (m == 0) return true;
    if (n == 0) return false;
 
    // If last characters of two strings are matching
    if (str1[m-1] == str2[n-1])
        return isSubSequence(str1, str2, m-1, n-1);
 
    // If last characters are not matching
    return isSubSequence(str1, str2, m, n-1);
}
Posted
Updated 6-Sep-18 20:58pm
Comments
Patrice T 7-Sep-18 1:53am    
And ?
you have a question ?

I beginner to programming, can you please provide pseudocode to me
 
Share this answer
 
Comments
Richard MacCutchan 7-Sep-18 4:47am    
You have tagged this C and Java, but which is it?
Richard Deeming 7-Sep-18 10:02am    
1) This is not a solution to your problem, and should not have been posted in the "Add your solution here" box.

2) THIS IS NOT A SOLUTION TO YOUR PROBLEM, and should not have been marked as the "accepted" solution.

3) We do not do your homework for you.
think about what your code should do: "Look up every new string whether it is already in my array?"

=> so you need to loop every time through the complete array.
a) use a for loop
b) when found you are done
c) after looping all entry you know that you havent found it.
bonus: (only than add it)

You can use some C++ tutorial to learn the basics.

Develop your code and pseudo code yourself to learn programming. Use always a verb and objects.

The first can be: "Ask numbers for input"
 
Share this answer
 
v2
Comments
Member 13602584 7-Sep-18 3:00am    
Can you please provide pseudocode, I beginner to programming

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900