Sobes.tech

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) { }

381

What is the search speed in HashMap (average and worst case)?

254

Why set the size of the first array (temp) equal to the length of the input array?

210

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) { }

207

Where exactly can an error occur without 'volatile' in Double-Checked Locking?

156

What is the search speed in LinkedList (average and worst case)?

153

Why does the code compare the order type using != instead of equals?

148

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; } }

144

How to fix the problem with the synchronized(instance) monitor when instance == null?

134

How could the solution be refactored using one collection instead of two (seen and temp)?

131
/2