Question
/* * * Find the last occurrence of the longest substring without repeating characters. * You are asked to implement the function longestSubstring() as specified
/* * * Find the last occurrence of the longest substring without repeating characters. * You are asked to implement the function longestSubstring() as specified below. * */ #include
int main(int argc, char** argv) { char str[MAX_LENGTH]; // buffer ifstream fin("tut02_input.txt"); if (!fin) { cout << "Input file not found."; exit(1); } int testcase = 0; fin >> testcase; for (int i = 0; i < testcase; i++) { fin >> str; Substring longest = longestSubstring(str); cout << "Case " << i + 1 << endl; printf("The substring (%d,%d) is %.*s ", longest.start, longest.length, longest.length, str + longest.start); cout << endl; } fin.close(); return 0; }
5 aaaa abababa abccba CPPisFun theQUICKbrownFOXjumpsOVERtheLAZYdog ========================================================================== ====== Below is the description of the input format and expected output. ========================================================================== ====== Input: The first line of input contains an integer T denoting the number of test cases. Each following line is a test case that contains a string of ASCII characters. Output: Case 1 The substring (3,1) is a Case 2 The substring (5,2) is ba Case 3 The substring (3,3) is cba Case 4 The substring (2,6) is PisFun Case 5 The substring (0,21) is theQUICKbrownFOXjumps
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started