Shop In Candy Store Geeks For Geeks
Problem Link: https://practice.geeksforgeeks.org/problems/shop-in-candy-store1145/1# (It is also the problem of the day for 28-04-2022) Solution: Using Arrays.sort and Without additional arraylist: class Solution{ static ArrayList<Integer> candyStore(int arr[],int n,int k){ ArrayList<Integer>ab=new ArrayList<Integer>(); Arrays.sort(arr); /*for(int i=0;i<arr.length;i++){ System.out.print(arr[i]+" "); } */ int start=0; int end=arr.length-1; int cost=0; while(start<=end){ cost=cost+arr[start]; start++; ...