/** * Find the person with the minimum age in a room with the maximum number of people * At the end of the solution method, call writeSolution(user, room) */
Java
How to solve the problem with NFT 50ms at current RT 150ms + 350ms? Suggest an architectural solution.
Have you worked with locks in databases? How did you acquire locks?
What are functional interfaces? Which ones do you know? What do they accept and what do they return?
Can any object be added to a TreeMap as a key?
What does the reduce method do?
[name] asked: what databases have you worked with? Postgres, Redis — that's clear, but what about non-relational ones like MongoDB or others?
Why did you use Spring Web for API Gateway instead of ready-made proxy solutions like Nginx, Envoy?
The database is large, indexes are built, the plan has been reviewed — what else can be done for optimization?
How do LinkedList and HashMap differ? How does LinkedHashMap differ from HashMap?
Have you ever explained to a client or analyst why a task takes 2 days instead of 10?
What approaches do you use for versioning REST API to ensure compatibility between different clients, and what difficulties have you faced?
```java import java.util.*; import java.lang.*; import java.io.*; class Codechef { public static void main (String[] args) throws java.lang.Exception { var autoNumbers = List.of(List.of("A123BC", "B421FT"), List.of("O543EC","B421FT", "I222OA")); autoNumbers.stream().flatMap(Collection::stream).flatEach(System.out/System.out.println()); Map<String, String> numberMap = autoNumbers.stream().flatMap(Collection::stream).collect(Collectors.toMap( n -> n, n -> n.replaceAll("[^0-9]", ""))); System.out.println(numberMap); } } ```
Tell about what you have translated from synchronous to asynchronous mode and why it was done.
@Data @Entity @Table(name = "_store") public static class Book { @Id private String id; private String title; private String author; private int price; @Transient private String tmp; @Enumerated(EnumType.STRING) private BookType type; } public enum BookType { COMMON, PREMIUM; }
```java // 2 public class Interfaces { public static void main(String[] args) { A a = new A() {}; B b = new B() {}; AB ab = new AB(); a.print(); b.print(); ab.print(); } public interface A { default void print() { System.out.println("interface A"); } } public interface B extends A { default void print() { System.out.println("interface B"); } } public static class AB implements A, B { } } ```
Tell about the hotspot problem in Cassandra and how you solved it.
How do you feel about AI potentially replacing developers? How do you see development in 2-3 years?
import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class badCounter { public static Map<String, Integer> mapOfBadNames = new HashMap<>(); protected void doProcessing(String filePath) throws IOException { try { FileInputStream fis = new FileInputStream(filePath); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); while((br.readLine())!=null){ processWords(br.readLine()); } br.close(); fis.close(); } catch (IOException | NullPointerException ex) { System.out.println(ex.getMessage()); } } private void processWords(String line) { Arrays.stream(line.split(" ")) .map(String::trim) .forEach(word -> { if(mapOfBadNames.containsKey(word)){ mapOfBadNames.put(word, mapOfBadNames.get(word)+1); } else{ mapOfBadNames.put(word, 1); } }); } public void writeResultToFile(String path) throws IOException { try { PrintWriter out = new PrintWriter(path); out.println("word,frequency"); for(Map.Entry<String, Integer> entry : mapOfBadNames.entrySet()){ out.println(entry.getKey() + "," + entry.getValue()); } out.close(); } catch (NullPointerException | IOException ex) { throw new RuntimeException("Error writing to file", ex); } } public boolean isEverythingFine() { return true; } public static void main(String[] args) { badCounter bcn = new badCounter(); try { bcn.doProcessing("bad_input.txt"); bcn.writeResultToFile("result.csv"); bcn.doProcessing("bad_input1.txt"); bcn.writeResultToFile("result1.csv"); } catch (IOException ex) { System.out.println("Something went wrong"); } } }
Does the order of columns matter when creating a composite index?