Sobes.tech

employee table | name | lang | | Nick | C# | | Nick | SQL | | Eva | Rust | | Vika | SQL | | Ivan | Java | | Ivan | SQL | You need to write a query that finds the names of employees who know SQL and at least one other language. select name from employee group by name having COUNT(DISTINCT lang) >= 2;

157

How to solve the data inconsistency problem: an external call was successful, but saving to the database failed?

157

How do you feel about VK's initiative to create their own database, and how would you assess its quality and effectiveness?

Junior — Middle
156

/** * Interface for interacting with ATM hardware. */ interface Hardware { /** * Returns an array with the number of banknotes by denominations 50, 100, 500, 1000, 5000. * The method is slow and creates noise. * * @return array where each element corresponds to the number of banknotes of a certain denomination. * For example, [10, 20, 30, 40, 50] means: * - 10 banknotes of 50 rubles * - 20 banknotes of 100 rubles * - 30 banknotes of 500 rubles * - 40 banknotes of 1000 rubles * - 50 banknotes of 5000 rubles */ int[] getBillsCounts(); /** * Loads the specified banknotes into the dispensing box. * * @param billsCounts array with the number of banknotes by denominations [50, 100, 500, 1000, 5000]. * For example, [0, 1, 0, 2, 0] means: * - 0 banknotes of 50 rubles * - 1 banknote of 100 rubles * - 0 banknotes of 500 rubles * - 2 banknotes of 1000 rubles * - 0 banknotes of 5000 rubles */ void giveBills(int[] billsCounts); } /** * Class for implementing ATM logic. * You need to write code here */ class MyATM { /** * ATM hardware. */ Hardware hardware; public boolean withdraw(int amount) { int[] counts = hardware.getBillsCounts(); int[] nom = {50, 100, 500, 1000, 5000}; int[] toGive = new int[5]; for (int i = 4; i >= 0; i--) { int needed = amount / nom[i]; int use = Math.min(needed, counts[i]); toGive[i] = use; amount -= use * nom[i]; } if (amount != 0) { return false; } hardware.giveBills(toGive); return true; } }

155

Tell me about your last project: what you did, what tasks were, what stack?

152

What are the consequences of creating an ObjectMapper as a class field (not through Spring)?

146

/** * The method calculates how many points the candidate earned, * saves the result to the database, and calls a callback about it to an external service */ public void process(Candidate c) { transactionTemplate.executeWithoutResult(status -> { Score s = interviewScoreMLService.compute(c); String body = objectMapper.writeValueAsString(Map.of(c.getName(), s)); Mono<ResponseEntity<Void>> request = WebClient.create() .post() .body(BodyInserters.fromValue(body)) .retrieve() .toBodilessEntity(); scoreRepository.saveScore(s); }); }

134
/2