Niuke AI interview questions

first round

  1. How to make and use static libraries and dynamic libraries, what is the
    difference ? Use the ar tool (archive) -> compile and link Dynamic library: gcc gets the .o file, and gets position-independent code -> gcc gets the dynamic library -> compile and link Differences: ● The static library is copied to the program link stage In the program, the dynamic library is loaded into the memory and called when the program is running. ● The loading speed of the static library is fast, and the portability is high, but it consumes system resources, and it is troublesome to update, deploy and release. ● The loading speed of the dynamic library is slow, and the dynamic library needs to be provided for transplantation. Resource sharing between processes, update, deployment, and release are relatively simple.








  2. Let’s talk about the implementation principle of HashMap
    Before jdk1.7, HashMap was implemented based on arrays and linked lists, and used header insertion.
    After jdk1.8, there has been a big change in resolving hash conflicts. When the length of the linked list is greater than the threshold (8 by default) (it will be judged before converting the linked list into a red-black tree, if the length of the current array is less than 64, then it will be When you choose to expand the array first instead of converting to a red-black tree), convert the linked list into a red-black tree to reduce the search time. Use tail insertion method.
    The default initialization size of HashMap is 16. When the sum of the number of elements in the HashMap is greater than the load factor * current capacity, it will be expanded, and the capacity will be doubled. (Here, note that it is not the number in the array, but the sum of the numbers of all elements in the array and in the chain/tree!)
  3. Why the Serializable interface needs to define the serialVersionUID constant
    The serialVersionUID constant is used to indicate the version of the current Serializable class to verify whether the loaded class is compatible with the serialized object.
    When serializing, the serialVersionUID of the current class will be written into the byte sequence. When deserializing, the serialVersionUID in the current byte stream will be compared with the serialVersionUID in the local object. If they are the same, serialization will continue. If If it is different, it will fail and report an error.
    The serialVersionUID constant value defaults to 1L.
  4. Talk about the underlying data structure of the zset type.
    The underlying storage structure of zset includes ziplist or skiplist. Use ziplist when the number of elements stored in the ordered set is less than 128 and the length of all elements stored in the ordered set is less than 64 bytes. , other times use skiplist.
    When ziplist is used as the underlying storage structure of zset, each collection element is stored using two compressed list nodes next to each other. The first node stores the members of the element, and the second element stores the score of the element.
    When skiplist is used as the underlying storage structure of zset, use skiplist to store elements and scores in order, and use dict to store the mapping relationship between elements and scores.
  5. Given a string array strs of size n, which contains n strings, write a function to find the longest common prefix in the string array and return this common prefix.
    insert image description here

Guess you like

Origin blog.csdn.net/AzirBoDa/article/details/126157104