@@ -0,0 +1,966 @@
+/**%0A * %0A */%0Apackage hackerRank;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Scanner;%0A%0A/**%0A * @author Arun.G%0A *%0A */%0Apublic class MarkandToys %7B%0A%0A%09/**%0A%09 * @param args%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09Scanner sc= new Scanner(System.in);%0A%09%09//get n and k%0A        int n= sc.nextInt();%0A        int k = sc.nextInt();%0A%0A        int arr%5B%5D = new int%5Bn%5D;%0A        //get the elements in array%0A        for(int i=0;i%3Cn;i++)%0A        %7B%0A            arr%5Bi%5D=sc.nextInt();  %0A        %7D%0A        //sort it in ascending order%0A        Arrays.sort(arr); %0A        //see how many low cost toys we can buy with the money%0A        int count=0;int sum=0;%0A        for(int i=0;i%3Carr.length;i++)%0A        %7B%0A            sum += arr%5Bi%5D;%0A           if(sum%3Ek)%0A                break;%0A           else%0A               count++; %0A        %7D%0A        //print the result%0A        System.out.println(count);%0A        %0A        //close the scanner%0A        sc.close();%0A%09%7D%0A%0A%7D%0A

Mark and Toys