Interview in Silicon Valley (Part 2) “Happy Ending

Tram Ho

Following part 1 , I would like to continue the interview story in Silicon Valley. After that failure, the unit continued to take the second candidate to interview. Unexpectedly, when Director of Software engineer used the same question set last time. That is a situation that is not taken into account, because everyone thinks that he will ask another question. The result is that everyone knows, again

Don’t skip Part 1:

How did I interview in Silicon Valley?

However, with the motto of not giving up, never give up because if the interview fail means losing the project, affecting the business of the company. According to the leadership’s instructions, the participants entered, the entire record of the interview was heard again, dissected as a video analysis of football matches. Interview questions are Google search, sent to experts for advice. Even posted on the technology forum for reference (people also jump to fight with each other, garlic, each answer 1, stone bricks throw enough to build houses). I myself have to try to understand Google, consult many people to find the best answer

Related image

After a series of expert commentaries, the most accurate answer can be found

Question 1: Write code example of Singleton class

Actually there are several types of Singleton class code in Java, of which there are 2 common types

Early Instantiation :

Create an instance at the time of class loade time

Lazy Loading

Instance is created when Singleton class is used for the first time, as the code presented in part 1

It is necessary to present a multi-threaded case as part 1. The skirt of the skirt must analyze each case, assess the advantages and disadvantages

And 1 Singleton can be called as man standard temporarily as follows:

The most important is this question, which determines the fail or pass

Is there a case where Singleton has created multiple instances?

The correct answer here is YES

Java has a concept of Reflection , an API that allows checking and modify behavior of methods, class at runtime

reflection

This reflection can cause the destroy of the singleton property of the singleton class

Leading to the destroyed singleton and creating two different objects belonging to the sample class

There is also a case where serialize / desterilize object also occurs

https://gurunh.com/2018/05/singleton-co-thuc-su-de/

Quote the original sentence in Head First Design Patterns

Hãy giữ lại IF bạn đang dùng nhiều bộ nạp ảnh ; này không thể gỡ bỏ tiến trình Singleton và kết quả trong nhiều instances.

Question 2: Coding

Write reverse character string

In addition to using element-inverting loops as part 1 , recursive algorithms can be used

The simpler code does not have to be repeated, but I do not think recursion is the most optimal because in the recursive function will be called multiple times and the stack memory will be superimposed with easily cause data about memory

Post code number 2

For positive integer n, find the number of ways to divide n into 5 smaller positive numbers so that it is still n

For example, n = 5 then output 1 because there is only 1 case (1, 1, 1, 1, 1)

N = 12 then there are 7 ways

Thanks to the help of Guc Go, it was discovered that behind this problem is a sky of mathematical knowledge

https://www.mathpages.com/home/kmath556/kmath556.htm

After reading it, I feel stupid

Great type of formula to find this way. N is a positive number to divide, K is a positive number <N

Briefly replace the type of farmers like this.

General statement: give candy to k babies, ask how many ways? (n, k positive)
Summary of solutions:

  • Evenly spread n candies to the table, notice there are n – 1 space between the candies
  • We have k babies -> need to insert k-1 partition to produce k spaces -> the answer is convolution (k-1) of (n-1), or (n-1) C (k-1 )

N = 7, k = 5 according to the convolutional combination, there are 15 specific ways:

{2, 2, 1, 1, 1}
{2, 1, 2, 1, 1}
{2, 1, 1, 2, 1}
{2, 1, 1, 1, 2}

{1, 2, 2, 1, 1}
{1, 2, 1, 2, 1}
{1, 2, 1, 1, 2}

{1, 1, 2, 2, 1}
{1, 1, 2, 1, 2}

{1, 1, 1, 2, 2}
(Actually there is only 1 way 2 numbers 2 and 3 number 1)

{3, 1, 1, 1, 1}
{1, 3, 1, 1, 1}
{1, 1, 3, 1, 1}
{1, 1, 1, 3, 1}
{1, 1, 1, 1, 3

(Actually there is only one way is 1 number 3 and 4 number 1)

However, because the problem does not care to order, it is necessary to add steps to eliminate the same results

Question 3: Question about system read data 99%, 1% write, what kind of data should you choose

The answer is ArrayList as part 1 , but in the case of multithreading, you can still use ArrayList but not share this list between threads. In short, handle with care, goods are easy to use

Or another answer as follows (Please advise of a Java player)

If it is a single-thread environment, using ArrayList is better than LinkedList in this case (especially when the list is relatively large) because ArrayList is random access while the LinkedList is not.

In return, adding, removing elements on the ArrayList will be worse in performance than LinkedList (due to having to handle the backed array). Of course, the performance of the system cannot be based entirely on qualitative calculations, but should be based on monitor tools with specific numbers.

If the multi-thread environment should use CopyOnWriteArrayList, the reason is that it ensures thread-safe during the implementation of the read () function in the CopyOnWrite model it does not require the use of lock.

However, this question should be asked back because it lacks the necessary information to get the correct answer

Original proof of a senior

Read what is read, write is write ntn, retort always has plus points. The problem for that cannot be enough to judge. For example, read random read more array, but sequential read the same. Write too, if write at the end, the array is the fastest. Advanced slashing, if the number of extremely large elements and sequential read, the array will have a clear advantage because the memory is allocate contiguous and not fragment like the linked list. So it fits into the cache line, because this bottle neck is mainly in memory, and if fragmenting the cache, it will fly a few hundred cycles right away.

Question 4: Do you have a service expose API for the client, if you use GET api call service via HTTPS, do you feel secure?

In case of sensitive data must include in GET request, it will violate security best practices. Full URL query parameters (including query parameters) of GET requess will be logged in server logs and there is a risk of unauthorized access. In the case of data on the query parameters should not appear in logs, you should use POST instead of GET

OK, so after collecting all the necessary information, the team builds into a set of interview questions including questions and answers. It’s the same type of university entrance exam.

The next job was to give the title to a third young man for an interview, to pray for the old man to ask the right question

The third candidate has quite good English, the topic, the answers have been handed over and read first. Unlike the previous one, this time there is a full board of leaders present. Because determined this time, it is considered as losing the project, you hang nieu.

He did his best, and waited for candidate’s wind-cutting skills. I heard that the manager also went to Ba Vang temple to worship more than two dozen tubers for relief

The clock moves gradually until the interview time is 9:30, everyone is waiting …

Director of Software engineering appeared, a gentle smile.

The first question

Question 1) Write example code for Singleton class

Question 2) Write code to reverse the chain …

Question 3) ….

It is true that previous lifetimes are good, heavenly Buddha blesses maintenance, the questions are the same. The result is clear …

Emotion burst, it was old silver with lipstick. This time, I was able to read how to interview and not to trick me

Image result cho cơ sở dữ liệu »¡Ã²a

Happy Ending

But now I still can’t think about it, why is the tool sharing a set of questions for an interview?

Conclude

The old people said that “ The loser is the one who gives up”, the winner is the one who does not give up . Sometimes being successful requires a bit of luck. But luck is only available when you try your best. The success of this person may have to be exchanged with the contribution and sacrifice of the collective, but all for the common purpose.

Vietnamese IT engineers are highly appreciated for their professional skills but weak foreign languages
Top 10 predictions of the IT industry worldwide
Share the news now

Source : giaosucan .uf48d8abe5e0b17a9f2d92020ed93a273 { padding:0px; margin: 0; padding-top:1em!important; padding-bottom:1em!important; width:100%; display: block; font-weight:bold; background-color:#eaeaea; border:0!important; border-left:4px solid #34495E!important; text-decoration:none; } .uf48d8abe5e0b17a9f2d92020ed93a273:active, .uf48d8abe5e0b17a9f2d92020ed93a273:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; text-decoration:none; } .uf48d8abe5e0b17a9f2d92020ed93a273 { transition: background-color 250ms; webkit-transition: background-color 250ms; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; } .uf48d8abe5e0b17a9f2d92020ed93a273 .ctaText { font-weight:bold; color:inherit; text-decoration:none; font-size: 16px; } .uf48d8abe5e0b17a9f2d92020ed93a273 .postTitle { color:#000000; text-decoration: underline!important; font-size: 16px; } .uf48d8abe5e0b17a9f2d92020ed93a273:hover .postTitle { text-decoration: underline!important; } Kỹ sư CNTT Việt Nam được đánh giá cao về kỹ năng chuyên môn nhưng ngoại ngữ yếu .u2e81fd4f5ee5a3ebf056f9ca79b81331 { padding:0px; margin: 0; padding-top:1em!important; padding-bottom:1em!important; width:100%; display: block; font-weight:bold; background-color:#eaeaea; border:0!important; border-left:4px solid #34495E!important; text-decoration:none; } .u2e81fd4f5ee5a3ebf056f9ca79b81331:active, .u2e81fd4f5ee5a3ebf056f9ca79b81331:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; text-decoration:none; } .u2e81fd4f5ee5a3ebf056f9ca79b81331 { transition: background-color 250ms; webkit-transition: background-color 250ms; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; } .u2e81fd4f5ee5a3ebf056f9ca79b81331 .ctaText { font-weight:bold; color:inherit; text-decoration:none; font-size: 16px; } .u2e81fd4f5ee5a3ebf056f9ca79b81331 .postTitle { color:#000000; text-decoration: underline!important; font-size: 16px; } .u2e81fd4f5ee5a3ebf056f9ca79b81331:hover .postTitle { text-decoration: underline!important; } 10 dự đoán hàng đầu của ngành IT trên toàn thế giới