Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a string, with certain lowercase letters. You are allowed to do at most one operation on this string, where, you can delete an entire

Given a string, with certain lowercase letters. You are allowed to do at most one operation on this string, where, you can delete an entire substring from the given string. You need to tell, by doing the above-mentioned operation at most once, can you create the string"programming" from the given string.In case you can, print Yes, else, print No
Input Format -The first line of input contains a single integer T, denoting the number of test cases. Then, T strings follow. For each of those strings, you need to tell, if you can generate the substring "programming", by doing the given operation at most once.
Output Format -Print T lines, where each line shall contain a single string - Yes (if the job can be done) or No (if the job cannot be done). Constraints1<= T <=1001< string size <=1000*E Examples Input:4
programming
abcdprogramminabcd
rammingabcdprog
progabcdramming
Output:YesNoNoYes
Explanation:In the given example we have 4 test cases.In the 1st test case, string "programming", we already have "programming" string.In the 2nd test case, string "abcdprogrammingabcd", we can't obtain "programming" in at most 1 operation. We would need 2 operations to make it "programming" by deleting "abcd" prefix and "abcd" sufix.In the 3rd test case, string "rammingabcdprog", we can't obtain "programming" in any number of operations.In the 4th test case, string "progabcdramming",, we can deletethe substring "abcd" to make it "proarammina".Given function: static String[] canDeleteSubstring(String[] given_strings){// Write your code here}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions