Janu and Ram are close friends who task a lot about life. They go though a lot of inspiring “Quotes of Life”.
One fine day they had a small game.According to the game Ram will Read one of the Quote about life from the book and Jannu have to think a word about life in her mind without disclosing it to Ram.
Finally once Ram completed reading the quoted Jannu will say if the word she thought in her mind is there in the Quote read by Ram.
Can you convert the same scenario to a programming logic ?
If the work thought by Jannu was present in the Quote then you have to print “Exists” else print “Dosen’t Exists”.
Input:
The first input contains an integer T denoting the number of test cases.
Each test case consist of a string in 'lowercase'
Output:
Print "Exists" or "Dosen't Exists" in a separate line.
#include <stdio.h> #include <string.h> int M,N,i,j,res; int main() { int t; scanf("%d",&t); while(t--){ char string[100]; char p[100]; scanf("%s%s",string,p); M=strlen(p); N=strlen(string); res=0; for(i=0;i<=N-M;i++){ for(j=0;j<M;j++) if(string[i+j]!=p[j]) break; if(j==M){ res++; j=0; } } if(res>0)printf("Exists\n"); else printf("Dosen't Exists\n"); } return 0; }
INPUT_1:
2
loveforall
hatred
changetheworldbylove
world
OUTPUT:
Dosen’t Exists
Exists
INPUT_2:
4
diewithmemoriesnotdreams
memories
whatwethinkwebecome
think
determineyourpriority
priorities
alliswell
good
OUTPUT:
Exists
Exists
Dosen’t Exists
Dosen’t Exists
Morae Q!
- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.