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 = []
Buy now
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 = []
Program Screenshot:
Program Video:
Buy now
CONTACT DETAILS
For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1
Comments
Post a Comment