Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An array A consisting of N integers is given. A triplet of indices ( P , Q , R ) is called a triangke if
An array A consisting of N integers is given. A triplet of indices PQR is called a triangke if P AR
AQ AR AP
AR AP AQ
The perimeter of such traingle equals AP AQ AR
For example consider the following array A:
A
A
A
A
A
A
Triplet iss a triangle and its perimeter equals There is no other triangle in this array with a larger perimeter.
Note that the inequality must hold between PQR but it is accepted that eg AP AQ consider the following array A:
A
A
A
A
A
Triplet is a triangle and its perimeter equals
Write a fucntion in GoLang:
func SolutionA int int
that, given an array A on N integers returns the maximum perimeter of any triangle in this array. The function should return if there are no triangles. for example
A
A
A
A
A
A
the function should return as explained above. Given array A such that:
A
A
A
A
A
A
The function should return : the triangle with maximum perimeter is
While for an array A:
A
A
A
The function should return as it is impossible to create a triangle.
and for an array A:
A
A
A
A
A
the function should return as explained above.
Write an efficient algorithm for followiing assumption:
N is an integer within the range ;
each element of array A is an integer within the range
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started