**Problem Description**

Given two lines **a _{1}x + b_{1}y + c_{1} = 0 ** and

**NOTE:**

- If these lines don't intersect, return
**[-1, -1]**. - If lines intersects, point of intersection will have integer coordinates.

-10^{9} <= a_{1}, b_{1}, c_{1} <= 10^{9}

-10^{9} <= a_{2}, b_{2}, c_{2} <= 10^{9}

First argument is an integer array A of size 3 where A[0] = a_{1}, A[1] = b_{1} and A[2] = c_{1}.

Second argument is an integer array B of size 3 where B[0] = a_{2}, B[1] = b_{2} and B[2] = c_{2}.

Return an integer array C of size 2. C[0] = X and C[1] = Y where (X, Y) is the point of intersection.

Input 1:

A = [1, -1, 0] B = [1, 1, 0]

Input 2:

A = [1, -1, 1] B = [0, 1, -2]

Output 1:

[0, 0]

Output 2:

[1, 2]

Explanation 1:

Given two lines intersects at the origin i.e. (0, 0).

Explanation 2:

Given two lines are: x - y + 1 = 0 and y - 2 = 0. Put y = 2 in the first line equation. We get x = 1. So, the point of intersection is (1, 2).

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Intersection of Two Lines**

to access hints and editorial solutions for

Loading...