Codewars: Rust workspace for solving the 'Which are In?' kata
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
674 B

3 years ago
  1. ## Which Are In?
  2. Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2.
  3. **Example 1:**
  4. ```
  5. a1 = ["arp", "live", "strong"]
  6. a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
  7. returns ["arp", "live", "strong"]
  8. ```
  9. **Example 2:**
  10. ```
  11. a1 = ["tarp", "mice", "bull"]
  12. a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
  13. returns []
  14. ```
  15. **Notes:**
  16. Arrays are written in "general" notation. See "Your Test Cases" for examples in your language.
  17. In Shell bash a1 and a2 are strings. The return is a string where words are separated by commas.
  18. Beware: r must be without duplicates.