Posts

Showing posts from October, 2024

Hacker Rank Price Check Solution

 import java.io.*; import java.util.*; import java.util.stream.*; class Result {     /*      * Complete the 'priceCheck' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. STRING_ARRAY products      *  2. FLOAT_ARRAY productPrices      *  3. STRING_ARRAY productSold      *  4. FLOAT_ARRAY soldPrice      */     public static int priceCheck(List<String> products, List<Float> productPrices, List<String> productSold, List<Float> soldPrice) {         // A map to store product names and their corresponding prices         Map<String, Float> priceMap = new HashMap<>();                  // Populate the map with pro...