Ninja and Substrings Problem Statement
Ninja has to determine all the distinct substrings of size two that can be formed from a given string 'STR' comprising only lowercase alphabetic characters. These substrings must appear as contiguous sequences in 'STR'.
Example:
Input:
"abcd"
Output:
["ab", "bc", "cd"]
Input:
The first line contains a single integer 'T' representing the number of test cases. The next 'T' lines each contain a string 'STR'.
Output:
For each test case, output all unique contiguous substrings of size two from 'STR'. Each test case result should be presented on a new line.
Constraints:
- 1 <= T <= 5*103
- 2 <= |STR| <= 103
- Time limit: 1 sec
Note:
You are not required to print anything; it has been handled for you internally.
AnswerBot
1y
The task is to find all the different possible substrings of size two that appear in a given string as contiguous substrings.
Iterate through the string and extract substrings of size two
Store the subs...read more
Help your peers!
Add answer anonymously...
Top Gainsight Associate Software Engineer interview questions & answers
Popular interview questions of Associate Software Engineer
>
Gainsight Associate Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app