Update data_structures/arrays/intersection.rb

Co-authored-by: Vitor Oliveira <vbrazo@gmail.com>
This commit is contained in:
Jessica Kwok 2021-04-19 15:54:48 -07:00 committed by GitHub
parent 25d76f8944
commit db2d1b74a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,7 +78,10 @@ puts intersect(nums1, nums2)
#
# Approach 3: Two Pointers
#
# Time Complexity: O(n log n)
# Complexity analysis:
# Time Complexity: O(nlogn + mlogm), where n and m are the lengths of the arrays. We sort two arrays independently and then do a linear scan.
# Space Complexity: from O(logn+logm) to O(n+m), depending on the implementation of the sorting algorithm.
#
def intersect(nums1, nums2)
result = []