package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/mark-and-toys
 */
public class MarkAndToys {
    private static int maxToys(int[] prices, int money) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = in.nextInt();
        }
        System.out.println(maxToys(prices, k));
    }
}

@@ -14,16 +14,41 @@
 rrank;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -65,16 +65,16 @@
 canner;%0A
-
 %0A/**%0A * 
@@ -226,15 +226,246 @@
     
-// TODO
+Arrays.sort(prices);%0A        int numToys = 0;%0A        for (int i = 0; i %3C prices.length; i++) %7B%0A            if (money - prices%5Bi%5D %3C 0) %7B%0A                break;%0A            %7D%0A            money -= prices%5Bi%5D;%0A            numToys++;%0A        %7D
 %0A   
@@ -476,17 +476,23 @@
  return 
-0
+numToys
 ;%0A    %7D%0A

Solve Mark and Toys