Point Inside a Triangle
Updated
Problem statement
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[]) → booleanExamples
Example 1
triangle = [[0,0],[5,0],[0,5]]point = [1,1]return = trueThe point lies strictly inside.
Example 2
triangle = [[0,0],[5,0],[0,5]]point = [3,3]return = falseThe point lies beyond the hypotenuse.
Example 3
triangle = [[0,0],[5,0],[0,5]]point = [0,2]return = trueAn edge point counts as inside.
Constraints
triangle.length == 3, every coordinate row has length 2, andpoint.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