text: Minimum length of the shortest path of a triangle | function to get the minimum length of the shorter side of the triangle ; traversing through each polets on the plane ; if sum of a polets is greater than the previous one , the maximum gets replaced ; prlet the length ; initialize the number of polets ; polets on the plane
code: function shortestLength ( n , x , y ) { let answer = 0 ; let i = 0 ; while ( n != 0 && i < x . length ) { if ( x [ i ] + y [ i ] > answer ) answer = x [ i ] + y [ i ] ; i ++ ; } document . write ( " " + answer + " " ) ; document . write ( " " + " " + answer + " " + " " + answer + " " ) ; } let n = 4 ; let x = [ 1 , 4 , 2 , 1 ] ; let y = [ 4 , 1 , 1 , 2 ] ; shortestLength ( n , x , y ) ;