Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ help // Header Files #include #include #include using namespace std; /* * inputStr, represents the given string for the puzzle */ void funcSubstring (string

C++ help

image text in transcribed

// Header Files

#include

#include

#include

using namespace std;

/*

* inputStr, represents the given string for the puzzle

*/

void funcSubstring (string inputStr)

{

// Write your code here

}

int main()

{

//input for inputStr

string inputStr;

getline(cin,inputStr);

funcSubstring(inputStr);

return 0;

Question Ray likes puzzles. One day, he challenged Ansh with a puzzle to find a string that is the same when read forwards and backwards. Write an algorithm to find the substring from the given string that is the same when read forwards and backwards. Input The input consists of a stringinputstr, representing the given string for the puzzle. Output From the given string, print a substring which is the same when read forwards and backwards. Note If there are multiple sub-strings of equal length, choose the lexicographically smallest one. If there are multiple sub-strings of different length, choose the one with maximum length. If there is no sub-string that is the same when read forwards and backwards print "None". Sub-string is only valid if its length is more than 1. Strings only contain uppercase characters (A-Z). Examples Example 1 : Input: YABCCBAZ Output: BCCBA Explanation: Given string is "YABCCBAZ", in this only sub-string which is same when read forward and backward is "ABCCBA". Example 2: input: ABC Output: Nome Explanation: Given strine is "ABC", and no substring is present which is same when read forward and backward. So. the output is "None

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Verify the statement made in the remark following Example 10.2.

Answered: 1 week ago