Company: Nokia_14june
Difficulty: medium
You are tasked with analyzing a financial stock price chart. Given a collection of stock price records over various days, you must determine the minimum number of straight line segments required to connect all the data points when plotted in chronological order. Each line segment connects consecutive collinear points on the chart. Two or more consecutive points are considered collinear if they lie on the same straight line. Your goal is to find the optimal grouping of consecutive collinear points such that the total number of line segments needed to represent the entire chart is minimized. Function Description You need to implement the function minimumLineSegments . This function takes the number of records and an array of day-price pairs, sorts them by day, and calculates the minimum number of straight line segments needed to connect all points in sequence. Parameters N : An integer representing the number of stock price records. stockRecords : A 2D integer array where each element st