Input: a= [3, 4, 5, 6, 7, 15]
min_element = a.min
max_element = a.max
new_missing_elements = []
for i in (min_element..max_element)
new_missing_elements.push(i) unless a.include?(i)
end
print new_missing_elements
OUTPUT:
=>[8, 9, 10, 11, 12, 13, 14]
min_element = a.min
max_element = a.max
new_missing_elements = []
for i in (min_element..max_element)
new_missing_elements.push(i) unless a.include?(i)
end
print new_missing_elements
OUTPUT:
=>[8, 9, 10, 11, 12, 13, 14]
No comments:
Post a Comment