6 kyu

Unique Substring From Joined Strings

134 of 256obnounce

Description:

Write a function that takes two strings, A and B, and returns the length of the longest possible substring that can be formed from the concatenation of either A + B or B + A containing only characters that do not appear in both A and B.

Example:

Given the strings "piquancy" and "refocusing":
A = "piquancy"
B = "refocusing"
A + B = "piquancyrefocusing"
B + A = "refocusingpiquancy"

Since 'i', 'n', 'u', and 'c' appear in both A and B, all acceptable substrings without those characters are:
"p", "q", "a", "yrefo", "s", "g" (from A + B)
"refo", "s", "gp", "q", "a", "y" (from B + A)

Therefore, it would be correct to return 5: the length of "yrefo".

Strings
Arrays
Algorithms

Stats:

CreatedJul 3, 2016
PublishedJul 3, 2016
Warriors Trained735
Total Skips52
Total Code Submissions2859
Total Times Completed256
Java Completions134
Ruby Completions63
Swift Completions65
Total Stars17
% of votes with a positive feedback rating91% of 71
Total "Very Satisfied" Votes61
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes3
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • obnounce Avatar
  • smile67 Avatar
Ad