[SOLVED] Finding unique string from two sorted reverse lexical order arrays in Java

Following is the question which I need the best answer for (best time complexity), along with a couple of test cases for it:

Given two arrays of strings a1 and a2, return a sorted array r in reverse lexical order that contains strings from a1 which are substrings of strings in a2. r should also contain unique strings without duplicates.

Example 1:

a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
r = ["strong","live","arp"]

Example 2:

a1 = ["tarp", "mice", "bull"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
r = []

Get your solution now 

Buy now

Comments

Popular posts from this blog

[SOLVED] Branch Coverage, Statement Coverage and Path Coverage | Java Unit Testing

HTML, PHP URL registration and lising program Internet Programming Spring 2016 Assignment #5