mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-25 21:58:57 +01:00
Update and rename arrays_intersection.rb to sorted_arrays_intersection.rb
This commit is contained in:
parent
da89bae931
commit
b101ef25d7
1 changed files with 3 additions and 3 deletions
|
@ -28,7 +28,7 @@
|
|||
# @param {Integer[]} arr2
|
||||
# @param {Integer[]} arr3
|
||||
# @return {Integer[]}
|
||||
def arrays_intersection(arr1, arr2, arr3)
|
||||
def sorted_arrays_intersection(arr1, arr2, arr3)
|
||||
result = []
|
||||
|
||||
# prepare three pointers to iterate through three arrays
|
||||
|
@ -57,11 +57,11 @@ end
|
|||
arr1 = [1, 2, 3, 4, 5]
|
||||
arr2 = [1, 2, 5, 7, 9]
|
||||
arr3 = [1, 3, 4, 5, 8]
|
||||
print(arrays_intersection(arr1, arr2, arr3))
|
||||
print(sorted_arrays_intersection(arr1, arr2, arr3))
|
||||
# Output: [1,5]
|
||||
|
||||
arr1 = [197, 418, 523, 876, 1356]
|
||||
arr2 = [501, 880, 1593, 1710, 1870]
|
||||
arr3 = [521, 682, 1337, 1395, 1764]
|
||||
print(arrays_intersection(arr1, arr2, arr3))
|
||||
print(sorted_arrays_intersection(arr1, arr2, arr3))
|
||||
# Output: []
|
Loading…
Reference in a new issue