Calculate the difference between the largest and smallest DELIVERY orders for each currency. Return the result for each currency, sorted in ascending order of the difference. /** * Returns a map of {currency (sorted by difference) – difference between the largest and smallest DELIVERY order for that currency}. * If there is only one order for a currency, the difference is 0. * Example input: * [ * Order(DELIVERY, "EUR", 2000), * Order(DELIVERY, "USD", 15), * Order(DELIVERY, "RUB", 200), * Order (PICKUP, "RUB", 1250), * Order (DELIVERY, "USD", 35), * Order (PICKUP, "USD", 55), * Order (DELIVERY, "RUB", 100) * ] * * Expected output: * ["EUR" -> 0.0, "USD" -> 20.0, "RUB" -> 100.0] * */ Map<String, Double> getMaxMinusMinDeliveryMapByCurrency(List<OrderData> orderDataList) { }
Java
What is the search speed in HashMap (average and worst case)?
Why set the size of the first array (temp) equal to the length of the input array?
Java Tasks 1. Write an implementation of the method: /** * @param a – array of numbers, the length of the array can be more than 10 million. * @return array of numbers with no duplicates. The order of numbers in the original array must be preserved. For duplicates, the last element should be kept, for example, for {2,1,4,2,3} the correct solution is {1,4,2,3}, not {2,1,4,3} If there is an element less than 0 in the input array, an error should be thrown. For example, for {2,3,-1,5} the processing should end with an error. */ public static double[] task(double[] a) { }
Can enums be inherited in Java?
What is a collision in HashMap?
Is Throwable a class or an interface?
Where exactly can an error occur without 'volatile' in Double-Checked Locking?
How does a LEFT JOIN work?
What is the search speed in LinkedList (average and worst case)?
Tell us about the device of HashMap.
Why does the code compare the order type using != instead of equals?
Why are two arrays (temp and result) needed?
What needs to be changed in this code to have a correct thread-safe implementation of the Singleton pattern? public class Singleton { private static final Singleton instance; public Singleton() { } public Singleton getInstance() { if (instance != null) { synchronized (instance) { if (instance == null) { instance = new Singleton(); } } } return instance; } }
What is the contract between hashCode and equals?
What is a red-black tree?
Tell us about Stream API — what it is and how you use it.
How to fix the problem with the synchronized(instance) monitor when instance == null?
How could the solution be refactored using one collection instead of two (seen and temp)?
Describe the exception hierarchy in Java