text: Find a point that lies inside exactly K given squares | Javascript implementation of the approach ; Driver Program to test above function
code: function PointInKSquares ( n , a , k ) { a . sort ( ) ; return a [ n - k ] ; } let k = 2 ; let a = [ 1 , 2 , 3 , 4 ] ; let n = a . length ; let x = PointInKSquares ( n , a , k ) ; document . write ( " " + x + " " + x + " " ) ;