Microsoft oa
Anonymous User
630

There is a line chart consiting of N points (numbered from 0 to N-1) connecte by line segments. The kth point has coordinates x = k, y = Y[k]. There are no horizontal lines; that is, no two consecutive points has the same y coordinate.
We can draw an infinitely long horizontal line.What is the maximum number of points of intersection of the line with the chart.
Example
Y = [1,2,1,2,1,3,2]
output = 5; a horizontal line at y = 1.5

Comments (0)