Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Triangle Validity Verification

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Triangle Validity Verification. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Photon's layout validation service receives three arrays containing corresponding side lengths. For each index, determine whether the three lengths can form a valid non-degenerate triangle.

Return a string array containing "YES" for valid triangles and "NO" otherwise, preserving the input order.

Formal Specification

Implement verify_triangles(a, b, c):

  • Input: Three integer arrays a, b, and c of equal length. For index i, the candidate sides are a[i], b[i], and c[i].
  • Output: A string array of the same length. The result at index i is "YES" if the three sides form a valid triangle, otherwise "NO".

A valid triangle must have three positive side lengths, and the sum of any two sides must be strictly greater than the third side.

Constraints

  • 1 <= a.length = b.length = c.length <= 10^5
  • -10^9 <= a[i], b[i], c[i] <= 10^9
  • Return results in the same order as the input triples
  • A valid triangle requires strictly positive side lengths

Function Signature

def verify_triangles(a, b, c):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output