Area of Triangle from Coordinates

Problem Given three points (x[i], y[i]) forming a triangle with at least one side parallel to an axis, compute its area (guaranteed integral).

Input / Output

  • Input: int arrays x[3], y[3].
  • Output: integer area.

Constraints

  • Coordinates up to 10^4 in magnitude; watch intermediate overflow if the limits are larger.

Example

  • (0,0), (4,0), (0,3) → area 6.
asked …
LeaderboardSalaryAccount