Given a list of points on a rectilinear path, identify the corners You are provided list of co-ordinates in form of pair as shown below:
$$li=[(576, 64), (576, 192), (448, 192), (320, 192), (320, 320), (192, 320), (192, 448), (192, 576), (320, 576), (448, 576), (576, 576), (704, 576), (832, 576), (960, 576)]$$
After modifying it according to goal.
Goal is to first plot all points in co-ordinate plane then join them now carefully we need to find out all corner points.
$$li=[(576, 64), (576, 192),(320, 192), (320, 320), (192, 320), (192, 576), (960, 576)]$$

Please refer the image I need the points which are encircled by a blue rectangle, where as red circled points are points that are provided in the problem.

I tried brute force approach it worked but yes please I need something better than that.
Converting a comment (with some adjustments) to an answer, as OP is satisfied with its validity ...

For each index $i$ (starting with the second, and ending with the next-to-last), compare $p_{i-1}$ to $p_{i+1}$: if (and only if) their $x$-coordinates differ and their $y$-coordinates differ, then (and only then) $p_i$ is a corner.
This algorithm ignores the first and last points, but those are already &quot;corners&quot; by declaration.
As OP has noted, the algorithm has complexity $O(n)$, as it simply steps through the list once.
Something like
while i &lt; N
    { Pi is a corner }
    while i &lt; N and X[i] == X[i+1]
        i+= 1

    { Pi is a corner }
    while i&lt; N and Y[i] == Y[i+1]
        i+= 1

Details need to be worked out.