Interesting substring
Description:
A string is 'interesting' if it's not a substring of another substring, i.e. if it's not contained in another substring. Given a string s
of substrings separated by space, return the longest 'interesting' substring and its position in the string relative to other substrings (its array-like position) in the following format:
["longest interesting substring", position of longest of interesting substring]
The following rules apply:
'Interesting' strings are case insensitive, so they will be returned in lowercase charcaters (e.g: "AAB" is equivalent to "aab" and evaluated as "aab").
If there is more than one longest 'interesting' substring, return the one with the smallest Unicode code point value.
Identical substrings are not 'interesting', since they are substrings of each other.
The substrings accept any character, except for extra spaces. Only a single space delimits two substrings. Other space characters should be ignored.
If
s
is an empty string or if there are no 'interesting' strings, the function should return the empty string ("").
. . .
Example 1 :
interesting("abc bde abcdef") => ["abcdef", 2]
In the string "abc bde abcdef"
the only interesting substring is "abcdef"
, because it is not a substring of "abc"
or "bde"
.
It's the 3rd substring in the original string, therefore it's position is 2
(array-like).
Example 2:
interesting("Whatever. We are what we are!") => ["whatever.", 0 ]
The only 'interesting' substrings are "whatever."
and "are!"
. Since "whatever."
is longer than "are!"
, the program will return the longest 'interesting' string and its corresponding position, 0
.
Similar Kata:
Stats:
Created | Aug 22, 2016 |
Warriors Trained | 59 |
Total Skips | 0 |
Total Code Submissions | 163 |
Total Times Completed | 15 |
JavaScript Completions | 15 |
Total Stars | 2 |
% of votes with a positive feedback rating | 88% of 8 |
Total "Very Satisfied" Votes | 6 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 7 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |