pls answer it fast pls friends
Attachments:
Answers
Answered by
1
Answer:
vapas aa jao di........
Answered by
2
Answer:
hello Bad girl...... xd... how are you?
Explanation:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int len = scan.nextInt();
int target = scan.nextInt();
int[] arr = new int[len];
for (int i = 0; i < len; i++) {
arr[i] = scan.nextInt();
}
Arrays.sort(arr);
int sum=0,count=0;
for (int i = 0; i < arr.length; i++) {
if(sum <= target){
sum += arr[i];
count++;
}
}
System.out.println(count-1);
}
}
Similar questions