To you looking for a job

It is said that march or April is the year-end season for many Internet companies. Many people are not satisfied with the year-end bonus, or feel that their career development is limited, and then run away. In this way, many departments will have hc vacancies due to personnel turnover. What I want to say here is that March and April are indeed the most hc seasons every year, but at the same time, it is the peak job-hopping season with great competition. If you want to find a good position, you need absolute strength. == Relatively speaking, in fact, the end of the year is a good time, as the saying goes, the army of iron camp water, the position of the Internet many posts are perennial recruitment, perennial lack of people, of course, HC is not rich, but at the end of the year, look at the opportunity of fewer people. After all, many people still care about the “year-end bonus”. So while you might lose some of your bonus by switching jobs at the end of the year, it’s also a lot less competitive. With fewer competitors, you might be able to stand out on “merit by luck.”

Fast worker interview

algorithm

The interviewer was very kind and said that you had used the Excel sheet. The number in the Excel sheet is usually like this: A…. Z AA… AZ BA… BZ, each corresponding to the number 0… 25, 26… 51, 52… 77. Analogically map numbers, give a string, and find the mapping result.

A for loop multiplies the result of character bits -‘A’+1 by 26*(the difference between the position of the character and that of the end), except for the character at the end. Do this kind of problem must first think, their own manual implementation. If you want to see the specific code answer, you can scan code to pay attention to [programmer’s way], the background reply “quick hand column conversion”.

The second algorithm, slightly off, how to achieve redis distributed lock.

If you haven’t been exposed to excessive concurrency, or haven’t used Redis as a distributed lock, then this algorithm is definitely not written, and such an algorithm, in general, is probably just for the idea. It’s a little hard to implement. For distributed locks, there are several pits:

  1. Lock, must set the expiration time (to prevent lock release failure, there is an expiration time, the lock can be automatically released). Locking and setting expiration times must be atomic operations. Otherwise, if the lock succeeds but the client crashes when setting the expiration time, setting the expiration time fails.
  2. Lock and lock release must be the same client. It’s identified by a unique ID.
  3. When releasing a lock, determining whether the lock belongs to you and releasing the lock must be atomic operations.

With that in mind, can you write the correct way to lock and unlock? Specific pit and the correct way to add unlock, pay attention to [programmer’s way], background reply “Redis distributed lock”.

basis

  • Mysql > create index; Select * from T where a=”a” and b=”b” and c=”c”, select * from T where a=”a” and c=”c” and b=”b” What are the guidelines for recommended indexes? Key points:
(1) Minimize like, but not completely unusable," (2) The primary key and foreign key of the table must have an index (3) Count (distinct (field)/count(*) (4) There is too little data in a single table to create an index (5)where(6) If there is both a single-field index and a joint index on these fields, you can generally delete the joint index. (7) The establishment of joint index needs careful analysis; Mysql > select * from left to right; mysql > select * from left to right; mysql > select * from left to right; Index, for example, is the key index (a, b, c) can support a | a, b | a, b, c three combinations are looking for, but does not support b, c to look up. An index is useful when the leftmost field is a constant reference. (9) Prefix indexes: Sometimes long character columns need to be indexed, which can make indexes large and slow. Usually, you can index the first part of the character, which can greatly save the index space, thus improving the index efficiency. The disadvantage is that it cannot be used for ORDER BY and GROUP BY operations, nor can it be used to overwrite an index (i.e. the data file itself is not accessed when the index itself contains all the data required for the query). (10) NULL causes the index to be NULLCopy the code

= and in can be out of order, such as a = 1 and b = 2 and c = 3. Create (a,b,c) indexes in any order. Mysql’s query optimizer will help you optimize them into a form that can be recognized by the indexes.

  • What data structures are in Redis and what are they used for? In redis, it is Sorted by Set. 3. Sorted Set: Sorted Set, Sorted Set, Sorted Set, Sorted Set, Sorted Set, Sorted Set The interviewer asked you about Sorted Set because you probably heard you say Sorted Set, so ask you to see if you really know it. If you don’t know it, you can’t bluff it out. Set a score parameter for each key. The zadd key score value command is used. There are some other commands to Google!

  • What does Java Volatile do? Public int incrment() {count++} Important: Volatile is primarily intended to ensure visibility when accessing multiple threads. We know that in order to improve the speed of accessing memory, the computer introduces the probability of working memory and main memory. When multithreading accesses data, it accesses the data of working memory, and the working memory between each thread is separately isolated. This can cause the same variable to “see its value” differently in different threads due to working memory. The volatile keyword, however, forces threads to read variables from main memory, and changes to variables are flushed directly to main memory, ensuring that changes to the same variable are immediately “seen” by other threads. This uses the technique of “memory barrier”. For count++, the operating system performs, instead of an atomic operation, three steps: 1) Load the count variable into memory. 2) Run count+1. 3) Store the results in memory. For non-atomic operations, any one step can be interrupted by another thread, so multithreading can be problematic. Volatile modifiers are also not acceptable because they are never atomic and are only visible, and the atomicity problem cannot be solved.

  • What memory is allocated in the JVM and what is it used for? Bottom line: JVM memory allocation is an interview question for almost every Java developer, and there could be several chapters to cover in this section alone. Here is just a brief introduction. JVM memory is divided into young generation and old generation, among which the young generation is divided into S0, S1 and Eden area. JVM adopts generational garbage collection algorithm, because in this way, it can make full use of object characteristics of young generation and old generation and maximize garbage collection efficiency.

  • Class objects are defined and assigned in the young generation.

  • Large objects or large arrays are allocated directly in the old age.

    Common garbage collection algorithms are copying algorithms, tag scavenging, tag collation, and then lead to different garbage collectors. Iteration of garbage collectors is the process of constantly discovering problems and optimizing. The collector used by the new generation is Serial, PraNew, Parallel Scavenge; Serial Old, Parallel Old, CMS Then combine their own understanding to say again!

  • What does a JVM stack do? Why does it have stacks and heaps? Is it ok to just use heap? Key points: The JVM stack is thread private, and some basic variables are stored on the stack. The Java stack holds stack frames, and each stack frame corresponds to a method called. Stack frames include Local Variables, the Operand Stack, and references to runtime constant pools of the class to which the current method belongs (the concept of runtime constant pools is covered in the methods section) Pool, method Return Address, and some additional information. When a thread executes a method, it creates a corresponding stack frame and pushes the stack frame. When the method completes execution, the stack frame is pushed off the stack. Why a stack after a heap? The stack exists to solve the problem of recursive calls. If there were only heap memory, there would be no recursive calls.

  • Distributed increment ID how to achieve, if using Redis to achieve, how to ensure the consistency with the database? Distributed increment ID generally uses the increment ID of MySQL, the INCR function of Redis, and the classic snowflake algorithm. The MySQL self-added ID is limited by the database access speed, and the QPS is not large in distributed use. To prevent redis from crashing, the current maximum value is usually recorded in MySQL or hbase. Or if you are designing a chat room, there must be a maximum seqId to persist the current chat room. If the Redis cluster crashes, take the maximum seqId from the persistent store and increment it.

  • What is the difference between ArrayList and LinkedList? The underlying implementation of ArrayList is array. The expansion of array is accomplished by replication constantly, so the performance of ArrayList is relatively poor when the storage capacity of data changes constantly. When you use an ArrayList, you typically expect the maximum amount of data. Arrays are best if you can use them directly. The underlying implementation of LinkedList is a LinkedList, which performs well when data is scaled up, but takes up more space than ArrayList for the same volume. LinkedList is recommended for frequent data expansion.

The content of the interview still has a lot, limited to space problem, next introduction. Programmers’ partners, feel lonely, then join the public number [programmer’s way], communicate together, out of our programmer’s way!