DeepinTech Backend Interview Cheat Sheet: HashMap, Locks, MySQL, Redis & Salary Tips
This article shares practical advice for DeepinTech offline interviews—including faster hiring, high salary packages for AI‑focused backend roles, and a comprehensive set of interview questions covering HashMap internals, Java locking mechanisms, Spring Boot benefits, MySQL indexing, B+Tree structures, Redis persistence, memory eviction policies, and a thread‑safe stack implementation in Java.
DeepinTech (formerly Sangfor) has started offline interviews, which are generally easier and faster than online ones, allowing candidates to receive offers within a day and offering senior‑level salaries for AI‑related backend positions.
Salary Overview
AI development engineers start at a monthly base of 25K CNY for undergraduates and 30K CNY for master’s graduates; with bonuses the total annual package can exceed 500‑600K CNY. AI algorithm positions are even higher, ranging from 30K‑45K CNY (undergrad) to 35K‑50K CNY (master). The compensation rivals top internet companies.
Interview Questions (First Round)
1. What is the principle of HashMap?
Before JDK 1.8, HashMap used an array of linked lists; when multiple keys hashed to the same bucket, they formed a linked list with O(n) lookup. Starting with JDK 1.8, if a bucket’s list exceeds eight elements it is transformed into a red‑black tree, giving O(log n) lookup, and the tree reverts to a list when the size drops below six.
2. What locks are available in Java?
Built‑in lock (synchronized) : basic monitor lock with four levels – no‑lock, biased, lightweight, and heavyweight.
ReentrantLock : explicit lock class offering interruptible lock acquisition, timed lock, and fairness options.
ReadWriteLock : allows multiple concurrent readers but only one writer, improving concurrency for read‑heavy workloads.
Optimistic vs. Pessimistic locks : pessimistic locks (e.g., synchronized, ReentrantLock) lock resources before access; optimistic locks use version numbers or timestamps to detect conflicts at commit time.
Spin lock : busy‑wait loop (often implemented with CAS) that repeatedly checks lock availability, suitable for very short wait times.
3. What are the benefits of Spring Boot?
Automatic configuration reduces boiler‑plate setup.
Starter dependencies enable quick integration of common libraries (databases, messaging, web, etc.).
Embedded servers (Tomcat, Jetty, Undertow) allow packaging as an executable JAR for easy deployment.
4. How are optimistic and pessimistic locks implemented in MySQL?
Pessimistic lock example (row‑level lock with SELECT ... FOR UPDATE):
BEGIN;
SELECT stock FROM goods WHERE id = 101 FOR UPDATE;
UPDATE goods SET stock = stock - 1 WHERE id = 101;
COMMIT;Optimistic lock uses a version column to detect conflicts:
SELECT stock, version FROM goods WHERE id = 101;
-- assume version = 3
UPDATE goods SET stock = stock - 1, version = version + 1 WHERE id = 101 AND version = 3;If the affected rows count is 0, a conflict occurred and the transaction must be retried.
5. What is a MySQL index?
InnoDB uses a B+Tree as the underlying data structure for indexes.
6. How does a B+Tree store data and indexes?
Only leaf nodes store actual row data; internal nodes store only index keys in primary‑key order. Each leaf node links to its predecessor and successor, forming a doubly linked list. A query traverses the tree from root to leaf, typically requiring 3‑4 I/O operations even for millions of rows.
7. What are the differences between B+Tree and B‑Tree?
B+Tree internal nodes store only keys, allowing more keys per node and a shallower tree.
B+Tree leaves are linked, making range queries fast.
B+Tree has redundant index nodes, simplifying insert/delete operations.
8. What persistence strategies does Redis provide?
Redis offers two main persistence mechanisms:
AOF (Append‑Only File) : every write command is appended to a log file.
RDB (Snapshot) : the in‑memory state is periodically saved as a binary dump.
AOF log implementation
After each write command Redis appends the command to the AOF file. On restart, Redis replays the logged commands to rebuild the dataset.
Three AOF fsync policies:
always : sync to disk after every write.
everysec : buffer writes and sync once per second.
no : let the operating system decide when to flush.
RDB snapshot implementation
AOF records commands, so recovery can be slow if the log is large. RDB saves the actual data snapshot, allowing fast loading without replaying commands.
Redis provides two commands to generate snapshots: SAVE (blocks the main thread) and BGSAVE (forks a child process, avoiding blockage).
9. What does Redis do when memory is full?
Redis triggers an eviction policy. The default on 32‑bit systems is noeviction , which rejects new writes when memory limit is reached. Other policies are divided into two groups:
Eviction among keys with an expiration time: volatile‑random , volatile‑ttl , volatile‑lru , volatile‑lfu .
Eviction among all keys: allkeys‑random , allkeys‑lru , allkeys‑lfu .
10. How to handle an oversized AOF or a full disk?
Run BGREWRITEAOF to rewrite the AOF file, keeping only the minimal set of commands needed for the current dataset. Enable automatic rewriting with auto‑aof‑rewrite‑min‑size and auto‑aof‑rewrite‑percentage. Mixed persistence (AOF with RDB preamble) can also reduce file size.
11. How to implement a concurrent stack?
Use a lock (e.g., ReentrantLock) to protect push, pop, peek, and isEmpty operations. Example Java implementation:
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class ConcurrentStack<T> {
private static class Node<T> {
T value;
Node<T> next;
Node(T value, Node<T> next) { this.value = value; this.next = next; }
}
private Node<T> top;
private final Lock lock = new ReentrantLock();
public void push(T value) {
lock.lock();
try { top = new Node<>(value, top); }
finally { lock.unlock(); }
}
public T pop() {
lock.lock();
try {
if (top == null) return null;
T v = top.value;
top = top.next;
return v;
} finally { lock.unlock(); }
}
public T peek() { lock.lock(); try { return top == null ? null : top.value; } finally { lock.unlock(); } }
public boolean isEmpty() { lock.lock(); try { return top == null; } finally { lock.unlock(); } }
}Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
