Form a Triangle Problem Statement

You are given an array of integers ARR with a length of N. Your task is to determine whether it's possible to construct at least one non-degenerate triangle using the values from the array as the sides of the triangle. If possible, return true; otherwise, return false.

Input:

The first line contains a single integer 'T' denoting the number of test cases.
For each test case:
The first line contains a single integer 'N' denoting the number of elements in the array.
The second line contains 'N' space-separated integers denoting the elements of the array.

Output:

For each test case, return "YES" if it is possible to form a non-degenerate triangle, otherwise return "NO". Each test case output should be printed on a separate line.

Example:

Input:
2
3
3 4 5
4
1 10 12 30
Output:
YES
NO

Constraints:

  • 1 ≤ T ≤ 100
  • 3 ≤ N ≤ 10^3
  • 0 ≤ ARR[i] ≤ 10^9

Note:

You are not required to print anything since this is already managed by the system. Your goal is to implement the functionality that returns the correct result.
AnswerBot
4mo

Check if it's possible to form a non-degenerate triangle using the given array elements as sides.

  • Iterate through each test case and check if the sum of any two sides is greater than the third side to ...read more

Help your peers!
Select
Add answer anonymously...

Indiamart Intermesh Software Engineer interview questions & answers

A Software Engineer was asked 9mo agoQ. What are your projects?
A Software Engineer was asked 9mo agoQ. What is your experience in technology?
A Software Engineer was asked Q. Form a Triangle Problem Statement You are given an array of integers ARR with a ...read more
Indiamart Intermesh Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits