Beats 100%🔥|| easy JAVA Solution✅
Code\n\nclass Solution {\n    public int timeRequiredToBuy(int[] nums, int k) {\n        int ans=0,val=nums[k];\n        for(int i=0;i<=k;i++) ans+=Math.min(val
# Code\n```\nclass Solution {\n    public int timeRequiredToBuy(int[] nums, int k) {\n        int ans=0,val=nums[k];\n        for(int i=0;i<=k;i++) ans+=Math.min(val,nums[i]);\n        for(int i=k+1;i<nums.length;i++){\n            if(nums[i]<val) ans+=nums[i];\n            else ans+=(val-1);\n        }\n        return ans;\n    }\n}\n```
['Java']