In input.each_with_index, the numbers stored in input are extracted one by one as num, and the numbers are numbered in the order in which they were extracted.
And when the fetched num is the same as target_num, in order to output the result of what number it is included in, # {index + 1} is set considering that the array starts from the 0th.
Recommended Posts