Find a point that lies inside exactly K given squares | Java implementation of the approach ; Driver Program to test above function
import java . io . * ; import java . util . * ; class GFG { static int PointInKSquares ( int n , int a [ ] , int k ) { Arrays . sort ( a ) ; return a [ n - k ] ; } public static void main ( String [ ] args ) { int k = 2 ; int [ ] a = { 1 , 2 , 3 , 4 } ; int n = a . length ; int x = PointInKSquares ( n , a , k ) ; System . out . println ( " ( " + x + " , ▁ " + x + " ) " ) ; } }