ans is the number of polets of letersection of the line segments with the vertical lines
let ans = 0 ; for ( let i = 0 ; i < m ; i ++ ) { let x1 = segments [ i ] [ 0 ] ; let x2 = segments [ i ] [ 2 ] ;