FastPrepPoint Inside a Triangle
Problems/Point Inside a Triangle

Point Inside a Triangle

SambaNova Systems logoSambaNova Systems● MediumFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand SambaNova software-engineering phone report dated June 1, 2022 asks how to tell whether a point is inside a triangle, given all four coordinates on a plane. Our version is about 95% the same as the reported question.

Given three non-collinear integer triangle vertices and one integer point, return whether the point lies inside the triangle.

A point on an edge or vertex counts as inside. The vertices may be clockwise or counterclockwise.

Function

isPointInsideTriangle(triangle: int[][], point: int[]) → boolean

Examples

Example 1

triangle = [[0,0],[5,0],[0,5]]point = [1,1]return = true

The point lies strictly inside.

Example 2

triangle = [[0,0],[5,0],[0,5]]point = [3,3]return = false

The point lies beyond the hypotenuse.

Example 3

triangle = [[0,0],[5,0],[0,5]]point = [0,2]return = true

An edge point counts as inside.

Constraints

  • triangle.length == 3, every coordinate row has length 2, and point.length == 2.
  • Coordinates are between -10^9 and 10^9.
  • The triangle has nonzero area.

More SambaNova Systems Onsite Interview questions

  • Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
  • 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
  • Bomb Enemy Best CoordinatesONSITE INTERVIEW · Seen Jun 2022
  • Sum Nodes with an Even-Valued GrandparentONSITE INTERVIEW · Seen Jun 2022
  • Validate Binary Search TreeONSITE INTERVIEW · Seen Jun 2022
  • Deterministic Zigzag SortPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Maximum Area of IslandONSITE INTERVIEW · Seen Jun 2022
  • Task Scheduler with CooldownPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Parse Variable, Expression, and Application TreesPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Flip Equivalent Binary TreesONSITE INTERVIEW · Seen Oct 2021

Similar questions at other companies

  • Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Painting Arcs to Nearest Neighbors on a CircleSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Rasterize a Circle with Integer PixelsPure Storage · ONSITE INTERVIEWPure Storage interview questions
  • Meeting of Points Moving Toward Initial SuccessorsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • K Closest Points to the OriginWhatNot · PHONE SCREENWhatNot interview questions
  • Probability Two People MeetJane Street · PHONE SCREENJane Street interview questions
  • Max Points on a LineLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
  • Range of a Third CorrelationTower Research Capital · PHONE SCREEN
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
All SambaNova Systems interview questionsSee SambaNova Systems hiring insights
Saved
class Solution {
    public boolean isPointInsideTriangle(int[][] triangle, int[] point) {
        // write your code here
    }
}
Checking account…