Problem Analysis:

  • Observation: This is a Loop Problem. Given Range, need to find any two elements from the array, if the sum of two elements is greater than the distance between Peter to MJ then print ‘YES’ else ‘NO’.

  • Solution Idea: Peter Can shoot any two web-shooters, So, he can choose first maximum element and second maximum element from the array.

Say,

m1=First Maximum,
m2=Second Maximum.

m1=-1,m2=-1.

Iterate all over the array, if arr_element>m2, then assign m2=arr_element, then if m1<m2 swap them. This is how we can find m1,m2.

Statistics

90% Solution Ratio
abu_fayeemEarliest, Mar '22
sodiumfis_hFastest, 0.0s
abu_fayeemLightest, 131 kB
Sudipto.kumarShortest, 213B
Toph uses cookies. By continuing you agree to our Cookie Policy.