Bytedance client development school recruitment approved in advance

2020.7.10-Byte (Toutiao) client interview record

algorithm

1. Give 1 yuan, 2 yuan, 5 yuan, 10 yuan. How many ways are there to pay N yuan?
A: 1. Four-layer for loop, judge i 1+j 2+k 5+m 10 == N. Timeout; 2. DP.
2. In a two-dimensional character array, given a string, starting from any position, you can search up, down, left, and right.
A: DP. leetcode original question.
3. Reverse the LONG type integer.
A: LONG to string, str[::-1]. Later, I checked leetcode and found another solution. You can take the remainder %10 and find one digit at a time.

Overall, the difficulty level is no more than Leetcode Moderate. After looking at other headline interviews, I found that the basic DP is 80% of the required questions. Even if you don’t ask questions on one side, you can’t escape on the other two.

basic knowledge

The order of the following arrangement is basically consistent with the order of questions in the interview. Mainly from three aspects, the first is client knowledge; the second is basic computer professional knowledge such as network planning and operating systems; the third is understanding of programming languages ​​(mainly JAVA).

client

  1. The four major components of Android.
  • activity、service、content provider、broadcast receive
  1. What is the life cycle of the activity?
  • oncreate()->onstart()->onResume()->onRestart()->onPouse()->onStop()->onDestory()
**onCreate()**: 当点击activity的时候,系统会调用activity的oncreate()方法,在这个方法中会初始化当前布局setContentLayout()方法。
**onStart()**: onCreate()方法完成后,此时activity进入onStart()方法,当前activity是用户可见状态,但没有焦点,与用户不能交互,一般可在当前方法做一些动画的初始化操作。
**onResume()**: onStart()方法完成之后,此时activity进入onResume()方法中,当前activity状态属于运行状态 (Running),可与用户进行交互。
**onRestart()**: 此方法在按下home()之后,再次进入到当前activity的时候调用。调用顺序onPouse()->onStop()->onRestart()->onStart()->onResume().
**onPouse()**: 当另外一个activity覆盖当前的acitivty时,此时当前activity会进入到onPouse()方法中,当前activity是可见的,但不能与用户交互。
**onStop()**: onPouse()方法完成之后,此时activity进入onStop()方法,此时activity对用户是不可见的,在系统内存紧张的情况下,有可能会被系统进行回收。所以一般在当前方法可做资源回收。
**onDestory()**: onStop()方法完成之后,此时activity进入到onDestory()方法中,结束当前activity。
  1. ASCII encoding and Unicode encoding (extended UTF-8)
coding size Supported languages
ASCII 1 byte English
Unicode 2 (4) bytes Chinese English
UTF-8 1-6 bytes, 1 byte for English, 3 (4-6) bytes for Chinese characters Chinese English
  • The relationship between the three is actually progressive. The earliest ASCII only supports English. China's customized GBK is defined by high and low 127-bit ASC codes, which is between ASCII and Unicode. In order to unify the encoding worldwide, Unicode encoding was proposed . Under Unicode encoding rules, when transmitting characters in the ASCII table, transmission space and storage space will be wasted. So UTF-8 was finally proposed , which is characterized by adaptive address space, and each byte is identified by different beginnings of "0", "110" and "10".

Because of the limited understanding of the client, the interviewer did not inquire about relevant knowledge in depth.

computer basics

  1. Processes and threads (common and required)
  • Four points were answered during the interview:
    (1) The process is the basic unit of operating system resource allocation, and the thread is the basic unit of task scheduling and execution; (2)
    A process has multiple threads;
    (3) The process has its own independent Address space, threads share process data and use the same address space;
    (4) Thread context switching is faster and less expensive than process context switching.
    Extension: 80,000 hits explaining threads and thread pools
  1. Deadlock (common and must be tested)
  • Deadlock refers to a blocking phenomenon caused by two or more processes competing for resources or communicating with each other during execution.
    Not only processes are deadlocked, but threads are also deadlocked.
  1. Four conditions for deadlock
  • (1) Mutual exclusion condition: a resource can only be used by one process at a time;
    (2) Request and retention conditions: when a process is blocked due to requesting resources, it will keep the obtained resources;
    (3) No deprivation condition : The resources that have been obtained by the process cannot be forcibly deprived of them before they are used up;
    (4) Circular waiting conditions: A head-to-tail circular waiting for resources relationship is formed between several processes.
  1. Atomicity and visibility of the memory model (synchronized, volatile) (extension: lock)
  1. OSI seven-layer protocol model, TCP/IP five-layer protocol model, four-layer protocol model
  • ISO/OSI: application layer, presentation layer, session layer, transport layer, network layer, data link layer, physical layer
    TCP/IP: application layer, transport layer, network layer, data link layer and physical layer
    Four layers: application layer, transport layer, network layer, network interface layer
  1. XML namespace
  • XML namespaces provide a way to avoid element naming conflicts. Many companies often use namespaces as pointers to actual existing web pages that contain information about the namespace.
    Syntax: xmlns="namespaceURI"
    xmlns="http://www.w3.org/TR/html4/",
  1. IPv4 and IPv6
  1. TCP congestion control
  • Based on the basic concept of network planning, the goal of TCP congestion control is to maximize the utilization of the bandwidth of bottleneck links on the network. Mainly explain the principles of slow start, congestion avoidance, fast recovery and fast retransmission algorithms. Express it in your own words based on understanding.
    Detailed explanation of TCP congestion control
  1. http和https
  • The main differences between https and http are as follows:
    (1) The https protocol requires applying for a certificate from CA. Generally, there are fewer free certificates, so a certain fee is required.
    (2) http is a hypertext transfer protocol, and information is transmitted in plain text, while https is a secure SSL encrypted transmission protocol.
    (3) http and https use completely different connection methods and use different ports. The former is 80 and the latter is 443.
    (4) The http connection is very simple and stateless; the HTTPS protocol is a network protocol built from the SSL+HTTP protocol that can perform encrypted transmission and identity authentication, and is more secure than the http protocol.
    Detailed explanation of http and https protocols
  1. https status code
status code category express
1** Informational status code The server is receiving and the client continues to send requests.
2** success status code Server successfully received
3** Redirect status code The client takes more actions, confirm/select a new address to jump/repeat the application
4** Client error status code An error on the client side causes the server to be unable to process
5** Server error status code Server error or exception

The interviewer asked whether the "404" error occurred on the client side or the server side?
The reason is that the server did not find the page requested by the client. Generally, if a 404 exception is thrown when writing code, it is mostly because there are Chinese characters on the path or there is a problem with the way the path is written. It is not an exaggeration to say that it is a client error.

Language basics

  1. Abstract classes and interfaces
  • It is most important to understand the concepts of both. An abstract class (modifier: abstract) is an abstraction of essence, and an interface (modifier: interface) is an abstraction of actions. For example: Men and women are all human beings, and the essential human being is an abstract class; both humans and dogs can eat and sleep, and the two actions are interfaces. Therefore, a class inherits an abstract class (classes in JAVA have single inheritance characteristics), and a class can implement multiple interfaces.
  • Features and details. JAVA's abstract classes and interfaces are explained in detail in the novice tutorial. very useful.
    Rookie Tutorial: Abstract Class
    Rookie Tutorial: Interface
    In the introduction to interfaces, the difference between abstract classes and interfaces is mentioned.
  1. Rewrite and reload
  • Rewriting is the process of rewriting the implementation of methods of the parent class that are allowed to be accessed by the subclass. Neither the return value nor the formal parameters can be changed.
    Overloading is in a class, the method name is the same, but the parameters (type, order, number) are different. The return types can be the same or different.
    Note: Don’t remember the two names backwards. After you really understand it, you can also understand the difference between writing and uploading.
  1. Generics
  • Generics provide a compile-time type safety detection mechanism, which allows programmers to detect illegal types at compile time.
    The essence of generics is a parameterized type, which means that the data type being operated on is specified as a parameter.
    Chestnut:
    Write a generic method to sort an array of objects. Then, call this generic method to sort an array of integers, arrays of floats, arrays of strings, etc.
    For knowledge about generics, reading a blog is enough. Detailed explanation of generics + interview questions: Generics
  1. equals and ==
  • Understand the stack memory space.
    Basic data types are stored in stack memory. For example, int, double, boolean, etc. String is a reference type and a class.
    The reference to the object is stored in stack memory, and its own data value is stored in heap memory. For example, String a = "123", a is on the stack, and "123" is on the heap. The same is true for new.
    Understand the above concepts and the differences will be clear at a glance below.
    (1) For ==, the comparison is whether the values ​​are equal. For variables of
    basic data types , the "value" stored in them is directly compared to see whether they are equal;
    for variables of reference type, the address of the object pointed to is compared.
    (2) Regarding the equals method, note: the equals method cannot act on variables of basic data types. equals inherits the Object class and compares whether they are the same object.
    If the equals method is not overridden, the comparison is that the addresses of the objects pointed to by reference type variables are the same; if
    classes such as String and Date override the equals method, the contents of the pointed objects are compared.

Guess you like

Origin blog.csdn.net/qq_32301683/article/details/107248751
Recommended