Skip to content

Instantly share code, notes, and snippets.

@NFhbar
Created July 16, 2020 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NFhbar/c6a502a21d11ac8e46dcd2f57c2bb5df to your computer and use it in GitHub Desktop.
Save NFhbar/c6a502a21d11ac8e46dcd2f57c2bb5df to your computer and use it in GitHub Desktop.
Array intersection

Array Intersection, 🟢


Problem

Create a function FindIntersection(strArr) that reads an array of strings stored in strArr which will contain 2 elements: the first element will represent a list of comma-separated numbers sorted in ascending order, the second element will represent a second list of comma-separated numbers (also sorted). Your goal is to return a list containing the numbers that occur in elements of strArr in sorted order. If there is no intersection, return an empty array.

Constraints

None.

Examples

Input: ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"]
Output: [1, 4, 13]
Input: ["1, 3, 9, 10, 17, 18", "1, 4, 9, 10"]
Output: [1, 9, 10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment