Java implementation of the above approach
import java . util . ArrayList ; import java . util . Arrays ; class GFG { static class Line implements Comparable < Line > { int m , c ; public Line ( int m , int c ) { this . m = m ; this . c = c ; }