Draft

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:

  1. 'Interesting' strings are case insensitive, so they will be returned in lowercase charcaters (e.g: "AAB" is equivalent to "aab" and evaluated as "aab").

  2. If there is more than one longest 'interesting' substring, return the one with the smallest Unicode code point value.

  3. Identical substrings are not 'interesting', since they are substrings of each other.

  4. The substrings accept any character, except for extra spaces. Only a single space delimits two substrings. Other space characters should be ignored.

  5. 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.

Fundamentals
Strings
Arrays

More By Author:

Check out these other kata created by astelvida

Stats:

CreatedAug 22, 2016
Warriors Trained59
Total Skips0
Total Code Submissions163
Total Times Completed15
JavaScript Completions15
Total Stars2
% of votes with a positive feedback rating88% of 8
Total "Very Satisfied" Votes6
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • astelvida Avatar
  • Blind4Basics Avatar
Ad